1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 02:40:50 +01:00

utils/misc: Revert d4b0dedc2a

d4b0dedc2a ("utils/misc: add combined output option to
check_output") adds an option that combines stdout and stderr, but
their order is arbitrary (stdout may appear before or after
stderr). This leads to problems in adb_shell() when it tries to check
the error code. Now that adb_shell() doesn't use combined_output,
remove the option as there are no more users in devlib.

squash! utils/misc: Make the return of check_output consistent
This commit is contained in:
Javi Merino 2020-03-27 11:54:36 +00:00 committed by Marc Bonnici
parent 779b0cbc77
commit 7c79a040b7

View File

@ -155,8 +155,7 @@ check_output_logger = logging.getLogger('check_output')
check_output_lock = threading.Lock() check_output_lock = threading.Lock()
def check_output(command, timeout=None, ignore=None, inputtext=None, def check_output(command, timeout=None, ignore=None, inputtext=None, **kwargs):
combined_output=False, **kwargs):
"""This is a version of subprocess.check_output that adds a timeout parameter to kill """This is a version of subprocess.check_output that adds a timeout parameter to kill
the subprocess if it does not return within the specified time.""" the subprocess if it does not return within the specified time."""
# pylint: disable=too-many-branches # pylint: disable=too-many-branches
@ -171,10 +170,9 @@ def check_output(command, timeout=None, ignore=None, inputtext=None,
raise ValueError('stdout argument not allowed, it will be overridden.') raise ValueError('stdout argument not allowed, it will be overridden.')
with check_output_lock: with check_output_lock:
stderr = subprocess.STDOUT if combined_output else subprocess.PIPE
process = subprocess.Popen(command, process = subprocess.Popen(command,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=stderr, stderr=subprocess.PIPE,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
preexec_fn=preexec_function, preexec_fn=preexec_function,
**kwargs) **kwargs)
@ -188,8 +186,7 @@ def check_output(command, timeout=None, ignore=None, inputtext=None,
# Currently errors=replace is needed as 0x8c throws an error # Currently errors=replace is needed as 0x8c throws an error
output = output.decode(sys.stdout.encoding or 'utf-8', "replace") output = output.decode(sys.stdout.encoding or 'utf-8', "replace")
if error: error = error.decode(sys.stderr.encoding or 'utf-8', "replace")
error = error.decode(sys.stderr.encoding or 'utf-8', "replace")
if timeout_expired: if timeout_expired:
raise TimeoutError(command, output='\n'.join([output or '', error or ''])) raise TimeoutError(command, output='\n'.join([output or '', error or '']))