1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

Merge pull request #276 from marcbonnici/android_utils

android: Fixed issue using single quoted command with adb_shell
This commit is contained in:
setrofim 2016-11-02 15:34:55 +00:00 committed by GitHub
commit 7af5868c22

View File

@ -282,13 +282,16 @@ def adb_shell(device, command, timeout=None, check_exit_code=False, as_root=Fals
_check_env()
if as_root:
command = 'echo \'{}\' | su'.format(escape_single_quotes(command))
device_string = '-s {}'.format(device) if device else ''
full_command = 'adb {} shell "{}"'.format(device_string, escape_double_quotes(command))
device_part = ['-s', device] if device else []
device_string = ' {} {}'.format(*device_part) if device_part else ''
full_command = 'adb{} shell "{}"'.format(device_string,
escape_double_quotes(command))
logger.debug(full_command)
if check_exit_code:
actual_command = "adb {} shell '({}); echo \"\n$?\"'".format(device_string, escape_single_quotes(command))
adb_shell_command = '({}); echo \"\n$?\"'.format(command)
actual_command = ['adb'] + device_part + ['shell', adb_shell_command]
try:
raw_output, error = check_output(actual_command, timeout, shell=True)
raw_output, error = check_output(actual_command, timeout, shell=False)
except CalledProcessErrorWithStderr as e:
raw_output = e.output
error = e.error