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

Unified Diff: build/android/pylib/remote/device/remote_device_environment.py

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
Index: build/android/pylib/remote/device/remote_device_environment.py
diff --git a/build/android/pylib/remote/device/remote_device_environment.py b/build/android/pylib/remote/device/remote_device_environment.py
index ee32332c9f1857f02e964205f4c05a73aa4b8bea..eff4e90815261d5592404a5be5223e0b3cc74938 100644
--- a/build/android/pylib/remote/device/remote_device_environment.py
+++ b/build/android/pylib/remote/device/remote_device_environment.py
@@ -82,8 +82,12 @@ class RemoteDeviceEnvironment(environment.Environment):
def __enter__(self):
"""Set up the test run when used as a context manager."""
- self.SetUp()
- return self
+ try:
+ self.SetUp()
+ return self
+ except:
+ self.__exit__(*sys.exc_info())
+ raise
def __exit__(self, exc_type, exc_val, exc_tb):
"""Tears down the test run when used as a context manager."""
@@ -118,9 +122,25 @@ class RemoteDeviceEnvironment(environment.Environment):
if (device['name'] == self._remote_device
and device['os_version'] == self._remote_device_os):
return device['device_type_id']
- raise remote_device_helper.RemoteDeviceError(
- 'No device found: %s %s' % (self._remote_device,
- self._remote_device_os))
+ self._NoDeviceFound(device_list)
+
+ def _PrintAvailableDevices(self, device_list):
+ def compare_devices(a,b):
+ for key in ('os_version', 'name'):
+ c = cmp(a[key], b[key])
+ if c:
+ return c
+ return 0
+
+ logging.critical('Available Android Devices:')
+ android_devices = (d for d in device_list if d['os_name'] == 'Android')
+ for d in sorted(android_devices, compare_devices):
+ logging.critical(' %s %s', d['os_version'].ljust(7), d['name'])
+
+ def _NoDeviceFound(self, device_list):
+ self._PrintAvailableDevices(device_list)
+ raise remote_device_helper.RemoteDeviceError('No device found: %s %s' %
+ (self._remote_device, self._remote_device_os))
@property
def device(self):

Powered by Google App Engine
This is Rietveld 408576698