From 8f3200679cfa426cbd5c1e42dce55c0232894dc5 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Fri, 6 Nov 2020 16:22:01 +0000 Subject: [PATCH] host: Concatenate stdout and stderr from command output Previously any output from stderr was discarded for LocalTargets. Align the behaviour of `execute` to append any stderr output to stdout before returning. --- devlib/host.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devlib/host.py b/devlib/host.py index ccf66e0..ecf724d 100644 --- a/devlib/host.py +++ b/devlib/host.py @@ -104,7 +104,7 @@ class LocalConnection(ConnectionBase): command = 'echo {} | sudo -S -- sh -c '.format(quote(password)) + quote(command) ignore = None if check_exit_code else 'all' try: - return check_output(command, shell=True, timeout=timeout, ignore=ignore)[0] + stdout, stderr = check_output(command, shell=True, timeout=timeout, ignore=ignore) except subprocess.CalledProcessError as e: message = 'Got exit code {}\nfrom: {}\nOUTPUT: {}'.format( e.returncode, command, e.output) @@ -112,6 +112,7 @@ class LocalConnection(ConnectionBase): raise TargetTransientError(message) else: raise TargetStableError(message) + return stdout + stderr def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False): if as_root and not self.connected_as_root: