1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

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.
This commit is contained in:
Marc Bonnici 2020-11-06 16:22:01 +00:00 committed by setrofim
parent 2cfb076e4c
commit 8f3200679c

View File

@ -104,7 +104,7 @@ class LocalConnection(ConnectionBase):
command = 'echo {} | sudo -S -- sh -c '.format(quote(password)) + quote(command) command = 'echo {} | sudo -S -- sh -c '.format(quote(password)) + quote(command)
ignore = None if check_exit_code else 'all' ignore = None if check_exit_code else 'all'
try: 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: except subprocess.CalledProcessError as e:
message = 'Got exit code {}\nfrom: {}\nOUTPUT: {}'.format( message = 'Got exit code {}\nfrom: {}\nOUTPUT: {}'.format(
e.returncode, command, e.output) e.returncode, command, e.output)
@ -112,6 +112,7 @@ class LocalConnection(ConnectionBase):
raise TargetTransientError(message) raise TargetTransientError(message)
else: else:
raise TargetStableError(message) raise TargetStableError(message)
return stdout + stderr
def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False): def background(self, command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, as_root=False):
if as_root and not self.connected_as_root: if as_root and not self.connected_as_root: