Commit ffb40bac authored by segfault's avatar segfault

Return stdout when executing command in container

parent c26b47ab
......@@ -236,7 +236,7 @@ class ContainerManager(object):
except sh.ErrorReturnCode_1:
return False
def execute_command(self, command: str, timeout=30, handle_stderr_line: callable = None):
def execute_command(self, command: str, timeout=30, handle_stderr_line: callable = None) -> str:
logger.debug("Executing command in %r: '%s'", self.name, command)
exit_code = None
p = subprocess.Popen(["systemd-run", "--pipe", "--wait", "-M", self.name, "/bin/sh", "-c", command],
......@@ -266,6 +266,8 @@ class ContainerManager(object):
raise CommandFailedError("Command '%s' failed with exit code %s. stderr: %s" %
(command, exit_code, p.stderr.read()))
return p.stdout.read()
def execute_apt(self, command: str, timeout):
def handle_stderr_line(line):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment