]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: execute: Rename LOG_OUTPUT to INTERACTIVE
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 16 Jan 2021 11:16:01 +0000 (11:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 16 Jan 2021 11:16:01 +0000 (11:16 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/execute.c
src/libpakfire/include/pakfire/execute.h
src/pakfire/builder.py
tests/python/execute.py

index f5dea94a51b8040266150d9c64dc1956ab3ff390..aa471218d5d3085a00014fceb06cc00ae72ffcac 100644 (file)
@@ -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);
index 3fdd167e6df39dce2face78cd7a5641536e524d0..c2cfc310cbe9fd7e9f21c9602dd53dfb2f8c49f6 100644 (file)
@@ -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]);
index c9cb02c2dbd4f235ffe9d2234cf3b27d1e8d9c92..30713f02952d18f98f9b7b70f06f7cc926292538 100644 (file)
@@ -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 */
index 1b5c3e1573e55be1df891e1b85eac63540194a26..f60a6b8ef9563abb962dfc07149189ec146b19e6 100644 (file)
@@ -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)
index 5bdd033ea9a93716b36f430ca18391edf2b595ad..7dd1388daec4ba40c7bb8c136df1504df89798c5 100755 (executable)
@@ -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):