| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Environment setup and teardown for remote devices.""" | 5 """Environment setup and teardown for remote devices.""" |
| 6 | 6 |
| 7 import distutils.version | 7 import distutils.version |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 def _PrintAvailableDevices(self, device_list): | 280 def _PrintAvailableDevices(self, device_list): |
| 281 def compare_devices(a,b): | 281 def compare_devices(a,b): |
| 282 for key in ('os_version', 'name'): | 282 for key in ('os_version', 'name'): |
| 283 c = cmp(a[key], b[key]) | 283 c = cmp(a[key], b[key]) |
| 284 if c: | 284 if c: |
| 285 return c | 285 return c |
| 286 return 0 | 286 return 0 |
| 287 | 287 |
| 288 logging.critical('Available %s Devices:', self._device_type) | 288 logging.critical('Available %s Devices:', self._device_type) |
| 289 logging.critical(' %s %s %s', 'OS'.ljust(7), | 289 logging.critical( |
| 290 'Device Name'.ljust(20), '# Available') | 290 ' %s %s %s %s %s', |
| 291 'OS'.ljust(10), |
| 292 'Device Name'.ljust(30), |
| 293 'Available'.ljust(10), |
| 294 'Busy'.ljust(10), |
| 295 'All'.ljust(10)) |
| 291 devices = (d for d in device_list if d['os_name'] == self._device_type) | 296 devices = (d for d in device_list if d['os_name'] == self._device_type) |
| 292 for d in sorted(devices, compare_devices): | 297 for d in sorted(devices, compare_devices): |
| 293 logging.critical(' %s %s %s', d['os_version'].ljust(7), | 298 logging.critical( |
| 294 d['name'].ljust(20), d['available_devices_count']) | 299 ' %s %s %s %s %s', |
| 300 d['os_version'].ljust(10), |
| 301 d['name'].ljust(30), |
| 302 str(d['available_devices_count']).ljust(10), |
| 303 str(d['busy_devices_count']).ljust(10), |
| 304 str(d['all_devices_count']).ljust(10)) |
| 295 | 305 |
| 296 def _GetDeviceList(self): | 306 def _GetDeviceList(self): |
| 297 with appurify_sanitized.SanitizeLogging(self._verbose_count, | 307 with appurify_sanitized.SanitizeLogging(self._verbose_count, |
| 298 logging.WARNING): | 308 logging.WARNING): |
| 299 dev_list_res = appurify_sanitized.api.devices_list(self._access_token) | 309 dev_list_res = appurify_sanitized.api.devices_list(self._access_token) |
| 300 remote_device_helper.TestHttpResponse(dev_list_res, | 310 remote_device_helper.TestHttpResponse(dev_list_res, |
| 301 'Unable to generate access token.') | 311 'Unable to generate access token.') |
| 302 return dev_list_res.json()['response'] | 312 return dev_list_res.json()['response'] |
| 303 | 313 |
| 304 def _NoDeviceFound(self): | 314 def _NoDeviceFound(self): |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 def trigger(self): | 353 def trigger(self): |
| 344 return self._trigger | 354 return self._trigger |
| 345 | 355 |
| 346 @property | 356 @property |
| 347 def verbose_count(self): | 357 def verbose_count(self): |
| 348 return self._verbose_count | 358 return self._verbose_count |
| 349 | 359 |
| 350 @property | 360 @property |
| 351 def device_type(self): | 361 def device_type(self): |
| 352 return self._device_type | 362 return self._device_type |
| OLD | NEW |