Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1679)

Unified Diff: devil/devil/android/sdk/adb_wrapper.py

Issue 2808763004: [devil] Raise DeviceUnreachableError on device not found (Closed)
Patch Set: match specific device Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « devil/devil/android/forwarder.py ('k') | devil/devil/android/sdk/adb_wrapper_devicetest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devil/devil/android/sdk/adb_wrapper.py
diff --git a/devil/devil/android/sdk/adb_wrapper.py b/devil/devil/android/sdk/adb_wrapper.py
index 7f6b8d952ba5b2a34049a972491fd9e47de62626..4e0b7c2caca1987bbb84369dba836fc3a38e074e 100644
--- a/devil/devil/android/sdk/adb_wrapper.py
+++ b/devil/devil/android/sdk/adb_wrapper.py
@@ -37,6 +37,7 @@ DEFAULT_RETRIES = 2
_ADB_VERSION_RE = re.compile(r'Android Debug Bridge version (\d+\.\d+\.\d+)')
_EMULATOR_RE = re.compile(r'^emulator-[0-9]+$')
+_DEVICE_NOT_FOUND_RE = re.compile(r"error: device '(?P<serial>.+)' not found")
_READY_STATE = 'device'
_VERITY_DISABLE_RE = re.compile(r'Verity (already )?disabled')
_VERITY_ENABLE_RE = re.compile(r'Verity (already )?enabled')
@@ -253,14 +254,17 @@ class AdbWrapper(object):
else:
raise
- if status != 0:
- raise device_errors.AdbCommandFailedError(
- args, output, status, device_serial)
- # This catches some errors, including when the device drops offline;
- # unfortunately adb is very inconsistent with error reporting so many
- # command failures present differently.
- if check_error and output.startswith('error:'):
- raise device_errors.AdbCommandFailedError(args, output)
+ # Best effort to catch errors from adb; unfortunately adb is very
+ # inconsistent with error reporting so many command failures present
+ # differently.
+ if status != 0 or (check_error and output.startswith('error:')):
+ m = _DEVICE_NOT_FOUND_RE.match(output)
+ if m is not None and m.group('serial') == device_serial:
+ raise device_errors.DeviceUnreachableError(device_serial)
+ else:
+ raise device_errors.AdbCommandFailedError(
+ args, output, status, device_serial)
+
return output
# pylint: enable=unused-argument
« no previous file with comments | « devil/devil/android/forwarder.py ('k') | devil/devil/android/sdk/adb_wrapper_devicetest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698