mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
utils/android: Combine stdout and stderror by combining the strings in adb_shell()
check_output(combined_output=True) does not guarantee that stdout will come before stderr, but the ordering is needed in case check_exit_code is True, as we are expecting the exit code at the end of stdout. Furthermore, the exceptions can't report what is stdout and what is stderr as they are combined. Partially revert 77a6de94537b ("utils/android: include stderr in adb_shell output") and parse output and err independently. Return them combined from adb_shell() to keep the functionality that 77a6de94537b was implementing.
This commit is contained in:
parent
7c79a040b7
commit
7780cfdd5c
@ -509,7 +509,7 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
|
|||||||
|
|
||||||
logger.debug(' '.join(quote(part) for part in parts))
|
logger.debug(' '.join(quote(part) for part in parts))
|
||||||
try:
|
try:
|
||||||
raw_output, _ = check_output(parts, timeout, shell=False, combined_output=True)
|
raw_output, error = check_output(parts, timeout, shell=False)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise TargetStableError(str(e))
|
raise TargetStableError(str(e))
|
||||||
|
|
||||||
@ -529,8 +529,8 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
|
|||||||
if exit_code.isdigit():
|
if exit_code.isdigit():
|
||||||
if int(exit_code):
|
if int(exit_code):
|
||||||
message = ('Got exit code {}\nfrom target command: {}\n'
|
message = ('Got exit code {}\nfrom target command: {}\n'
|
||||||
'OUTPUT: {}')
|
'OUTPUT: {}\nSTDERR: {}\n')
|
||||||
raise TargetStableError(message.format(exit_code, command, output))
|
raise TargetStableError(message.format(exit_code, command, output, error))
|
||||||
elif re_search:
|
elif re_search:
|
||||||
message = 'Could not start activity; got the following:\n{}'
|
message = 'Could not start activity; got the following:\n{}'
|
||||||
raise TargetStableError(message.format(re_search[0]))
|
raise TargetStableError(message.format(re_search[0]))
|
||||||
@ -541,10 +541,10 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
|
|||||||
else:
|
else:
|
||||||
message = 'adb has returned early; did not get an exit code. '\
|
message = 'adb has returned early; did not get an exit code. '\
|
||||||
'Was kill-server invoked?\nOUTPUT:\n-----\n{}\n'\
|
'Was kill-server invoked?\nOUTPUT:\n-----\n{}\n'\
|
||||||
'-----'
|
'-----\nSTDERR:\n-----\n{}\n-----'
|
||||||
raise TargetTransientError(message.format(raw_output))
|
raise TargetTransientError(message.format(raw_output, error))
|
||||||
|
|
||||||
return output
|
return output + error
|
||||||
|
|
||||||
|
|
||||||
def adb_background_shell(conn, command,
|
def adb_background_shell(conn, command,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user