From 8355fcf886c7462dfc0282cec1886ce659892f79 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Mon, 17 Oct 2016 10:49:53 +0100 Subject: [PATCH] adb_shell: handle zero stdout on error It looks like on recent systems, adb has started to correctly forward stderr from the target device to stderr on the host (wereas in the past, it got output to stdout on the host). This commit makes sure that stderr gets correctly forwarded to the coller in cases where return code checking was not enabled. --- wlauto/utils/android.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wlauto/utils/android.py b/wlauto/utils/android.py index 881c4da0..e4bd38f0 100644 --- a/wlauto/utils/android.py +++ b/wlauto/utils/android.py @@ -332,9 +332,13 @@ def adb_shell(device, command, timeout=None, check_exit_code=False, as_root=Fals raise DeviceError('adb has returned early; did not get an exit code. Was kill-server invoked?') else: # do not check exit code try: - output, _ = check_output(full_command, timeout, shell=True) + output, error = check_output(full_command, timeout, shell=True) + if output is None: + output = error + elif error is not None: + output = '\n'.join([output, error]) except CalledProcessErrorWithStderr as e: - output = e.output + output = e.error or e.output exit_code = e.returncode if e.returncode == 1: logger.debug("Got Exit code 1, could be either the return code of the command or mean ADB failed")