1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

android: Improve error when _setup_ls fails

If the ADB command fails (e.g. if you provide the wrong device ID), adb_command
raises a CalledProcessError. CalledProcessError doesn't print the output of the
failed command, so you get a useless error message.

This is relevent here in particular as _setup_ls is the first thing to run an
ADB command if a non-IP device ID is provided.

Catch the CalledProcessError and instead raise a HostError with the command
output in the exception message.
This commit is contained in:
Brendan Jackman 2017-03-01 18:49:27 +00:00
parent 6410318b49
commit 3298205b42

View File

@ -177,7 +177,12 @@ class AdbConnection(object):
# versions of the ls tool in Android pre-v7. # versions of the ls tool in Android pre-v7.
def _setup_ls(self): def _setup_ls(self):
command = "shell '(ls -1); echo \"\n$?\"'" command = "shell '(ls -1); echo \"\n$?\"'"
try:
output = adb_command(self.device, command, timeout=self.timeout) output = adb_command(self.device, command, timeout=self.timeout)
except subprocess.CalledProcessError as e:
raise HostError(
'Failed to set up ls command on Android device. Output:\n'
+ e.output)
lines = output.splitlines() lines = output.splitlines()
retval = lines[-1].strip() retval = lines[-1].strip()
if int(retval) == 0: if int(retval) == 0: