mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 10:11:17 +00:00
adb_shell: fixing handling of line breaks at the end of the output
- adb protcol uses "\r\n" for line breaks. This is not handled by Python's line break translation, as not a file. So spliting on '\n' when extracting the exit code resulted in stray '\r' in the output. - adb_shell expects exit code to be echoed on the same line. This may not have been the case if latest output from executed command was not a complete line. An extra echo will now ensure that the exit code will be on its own line even in that case.
This commit is contained in:
parent
c02a1118d7
commit
a06016a442
@ -239,13 +239,13 @@ def adb_shell(device, command, timeout=None, check_exit_code=False, as_root=Fals
|
||||
full_command = 'adb {} shell "{}"'.format(device_string, escape_double_quotes(command))
|
||||
logger.debug(full_command)
|
||||
if check_exit_code:
|
||||
actual_command = "adb {} shell '({}); echo $?'".format(device_string, escape_single_quotes(command))
|
||||
actual_command = "adb {} shell '({}); echo; echo $?'".format(device_string, escape_single_quotes(command))
|
||||
raw_output, error = check_output(actual_command, timeout, shell=True)
|
||||
if raw_output:
|
||||
try:
|
||||
output, exit_code, _ = raw_output.rsplit('\n', 2)
|
||||
output, exit_code, _ = raw_output.rsplit('\r\n', 2)
|
||||
except ValueError:
|
||||
exit_code, _ = raw_output.rsplit('\n', 1)
|
||||
exit_code, _ = raw_output.rsplit('\r\n', 1)
|
||||
output = ''
|
||||
else: # raw_output is empty
|
||||
exit_code = '969696' # just because
|
||||
|
Loading…
x
Reference in New Issue
Block a user