From: Michael Tremer Date: Sat, 16 Jan 2021 11:16:01 +0000 (+0000) Subject: libpakfire: execute: Rename LOG_OUTPUT to INTERACTIVE X-Git-Tag: 0.9.28~1285^2~852 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2aa9c5f5a926fd0a93614d581e0065c339be4aeb;p=pakfire.git libpakfire: execute: Rename LOG_OUTPUT to INTERACTIVE Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index f5dea94a5..aa471218d 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -351,15 +351,15 @@ static Py_ssize_t Pakfire_len(PakfireObject* self) { } static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* kwds) { - char* kwlist[] = {"command", "environ", "enable_network", "log_output", NULL}; + char* kwlist[] = {"command", "environ", "enable_network", "interactive", NULL}; PyObject* command = NULL; PyObject* environ = NULL; int enable_network = 0; - int log_output = 1; + int interactive = 0; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Opp", kwlist, &command, &environ, - &enable_network, &log_output)) + &enable_network, &interactive)) return NULL; // Check if command is a list @@ -449,9 +449,9 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* if (enable_network) flags |= PAKFIRE_EXECUTE_ENABLE_NETWORK; - // Log output? - if (log_output) - flags |= PAKFIRE_EXECUTE_LOG_OUTPUT; + // Interactive? + if (interactive) + flags |= PAKFIRE_EXECUTE_INTERACTIVE; // Execute command int r = pakfire_execute(self->pakfire, argv, envp, flags); diff --git a/src/libpakfire/execute.c b/src/libpakfire/execute.c index 3fdd167e6..c2cfc310c 100644 --- a/src/libpakfire/execute.c +++ b/src/libpakfire/execute.c @@ -244,7 +244,7 @@ PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* argv[], char* en cflags |= CLONE_NEWNET; // Make some file descriptors for stdout & stderr - if (flags & PAKFIRE_EXECUTE_LOG_OUTPUT) { + if (!(flags & PAKFIRE_EXECUTE_INTERACTIVE)) { if (pipe(env.stdout) < 0) { ERROR(pakfire, "Could not create file descriptors for stdout: %s\n", strerror(errno)); @@ -274,7 +274,7 @@ PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* argv[], char* en DEBUG(pakfire, "Waiting for PID %d to finish its work\n", pid); - if (flags & PAKFIRE_EXECUTE_LOG_OUTPUT) { + if (!(flags & PAKFIRE_EXECUTE_INTERACTIVE)) { // Close any unused file descriptors if (env.stdout[1]) close(env.stdout[1]); diff --git a/src/libpakfire/include/pakfire/execute.h b/src/libpakfire/include/pakfire/execute.h index c9cb02c2d..30713f029 100644 --- a/src/libpakfire/include/pakfire/execute.h +++ b/src/libpakfire/include/pakfire/execute.h @@ -29,7 +29,7 @@ int pakfire_execute_command(Pakfire pakfire, const char* command, char* envp[], enum { PAKFIRE_EXECUTE_NONE = 0, PAKFIRE_EXECUTE_ENABLE_NETWORK = (1 << 0), - PAKFIRE_EXECUTE_LOG_OUTPUT = (1 << 1), + PAKFIRE_EXECUTE_INTERACTIVE = (1 << 1), }; #endif /* PAKFIRE_EXECUTE_H */ diff --git a/src/pakfire/builder.py b/src/pakfire/builder.py index 1b5c3e157..f60a6b8ef 100644 --- a/src/pakfire/builder.py +++ b/src/pakfire/builder.py @@ -513,4 +513,4 @@ class BuilderContext(object): # Enter the shell self.pakfire.execute(["/usr/bin/bash", "--login"], - environ=self.environ, enable_network=True, log_output=False) + environ=self.environ, enable_network=True, interactive=True) diff --git a/tests/python/execute.py b/tests/python/execute.py index 5bdd033ea..7dd1388da 100755 --- a/tests/python/execute.py +++ b/tests/python/execute.py @@ -59,7 +59,7 @@ class Test(unittest.TestCase): self.pakfire.execute(["/usr/bin/does-not-exist"]) def test_execute_output(self): - self.pakfire.execute(["/bin/bash", "--help"], log_output=True) + self.pakfire.execute(["/bin/bash", "--help"]) # This is an interactive test which cannot be performed automatically #def test_shell(self):