]> git.ipfire.org Git - pbs.git/commitdiff
backend: command: Add option to return output
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 09:17:31 +0000 (09:17 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 09:17:31 +0000 (09:17 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py

index 52d01aa282376c5baafa29b14ed6e48136ea1956..d570e2634220b812f69cdc004e2253426ff4423c 100644 (file)
@@ -177,10 +177,12 @@ class Backend(object):
 
        # Commands
 
-       async def command(self, *args, krb5_auth=False, **kwargs):
+       async def command(self, *args, krb5_auth=False, return_output=False, **kwargs):
                """
                        Runs this shell command
                """
+               stdout = []
+
                # Authenticate using Kerberos
                if krb5_auth:
                        await self.krb5_auth()
@@ -208,11 +210,19 @@ class Backend(object):
                        # Strip newline
                        line = line.rstrip()
 
-                       log.info(line)
+                       # Log the output
+                       log.debug(line)
+
+                       # Store the output if requested
+                       if return_output:
+                               stdout.append(line)
 
                # Wait until the process has finished
                await process.wait()
 
+               if return_output:
+                       return "\n".join(stdout)
+
        async def krb5_auth(self):
                log.debug("Performing Kerberos authentication...")