PyObject* command = NULL;
PyObject* environ = NULL;
+ int nice = 0;
const char* kwlist[] = {
"command",
"environ",
+ "nice",
NULL,
};
// Parse arguments
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", (char**)kwlist, &command, &environ))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi", (char**)kwlist,
+ &command, &environ, &nice))
goto ERROR;
// Check if command is a list
goto ERROR;
}
+ // Set the nice level
+ if (nice) {
+ r = pakfire_jail_nice(jail, nice);
+ if (r < 0) {
+ errno = -r;
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto ERROR;
+ }
+ }
+
Py_BEGIN_ALLOW_THREADS
// Execute command
# Run a command that generates lots of lines
self.pakfire.execute(["/command", "lines", "100", "40"])
- #def test_nice(self):
- # self.pakfire.execute(["/command", "print-nice"], nice=5)
+ def test_nice(self):
+ self.pakfire.execute(["/command", "print-nice"], nice=5)
- #def test_nice_invalid_input(self):
- # """
- # Tries using an invalid nice value
- # """
- # with self.assertRaises(OSError):
- # self.pakfire.execute(["/command", "print-nice"], nice=100)
+ def test_nice_invalid_input(self):
+ """
+ Tries using an invalid nice value
+ """
+ with self.assertRaises(OSError):
+ self.pakfire.execute(["/command", "print-nice"], nice=100)
#def test_check_open_file_descriptors(self):
# """