1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00

utils/android: Log error in _ping()

Log any error happening in adb command ran by _ping() so it can be diagnosed.
Also fix possible deadlock by not using subprocess.PIPE along
subprocess.call(), as the documentation recommends against it.
This commit is contained in:
Douglas Raillard 2024-06-10 16:44:08 +01:00 committed by Marc Bonnici
parent 94f1812ab2
commit b8292b1f2b

View File

@ -571,11 +571,13 @@ def _ping(device, adb_server=None, adb_port=None):
adb_cmd = get_adb_command(device, 'shell', adb_server, adb_port) adb_cmd = get_adb_command(device, 'shell', adb_server, adb_port)
command = "{} {}".format(adb_cmd, quote('ls /data/local/tmp > /dev/null')) command = "{} {}".format(adb_cmd, quote('ls /data/local/tmp > /dev/null'))
logger.debug(command) logger.debug(command)
result = subprocess.call(command, stderr=subprocess.PIPE, shell=True) try:
if not result: # pylint: disable=simplifiable-if-statement subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
return True except subprocess.CalledProcessError as e:
else: logger.debug(f'ADB ping failed: {e.stdout}')
return False return False
else:
return True
# pylint: disable=too-many-locals # pylint: disable=too-many-locals