| 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 |
| 11 import random | 11 import random |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 from devil.utils import reraiser_thread | 14 from devil.utils import reraiser_thread |
| 15 from devil.utils import timeout_retry | 15 from devil.utils import timeout_retry |
| 16 from pylib import constants | |
| 17 from pylib.base import environment | 16 from pylib.base import environment |
| 18 from pylib.remote.device import appurify_sanitized | 17 from pylib.remote.device import appurify_sanitized |
| 19 from pylib.remote.device import remote_device_helper | 18 from pylib.remote.device import remote_device_helper |
| 20 | 19 |
| 21 class RemoteDeviceEnvironment(environment.Environment): | 20 class RemoteDeviceEnvironment(environment.Environment): |
| 22 """An environment for running on remote devices.""" | 21 """An environment for running on remote devices.""" |
| 23 | 22 |
| 24 _ENV_KEY = 'env' | 23 _ENV_KEY = 'env' |
| 25 _DEVICE_KEY = 'device' | 24 _DEVICE_KEY = 'device' |
| 26 _DEFAULT_RETRIES = 0 | 25 _DEFAULT_RETRIES = 0 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 device['name'], device['os_version']) | 272 device['name'], device['os_version']) |
| 274 self._device = device | 273 self._device = device |
| 275 return True | 274 return True |
| 276 return False | 275 return False |
| 277 | 276 |
| 278 def _FindDeviceWithTimeout(self): | 277 def _FindDeviceWithTimeout(self): |
| 279 """Find which device to use with timeout.""" | 278 """Find which device to use with timeout.""" |
| 280 timeout_retry.WaitFor(self._FindDevice, wait_period=1) | 279 timeout_retry.WaitFor(self._FindDevice, wait_period=1) |
| 281 | 280 |
| 282 def _PrintAvailableDevices(self, device_list): | 281 def _PrintAvailableDevices(self, device_list): |
| 283 def compare_devices(a,b): | 282 def compare_devices(a, b): |
| 284 for key in ('os_version', 'name'): | 283 for key in ('os_version', 'name'): |
| 285 c = cmp(a[key], b[key]) | 284 c = cmp(a[key], b[key]) |
| 286 if c: | 285 if c: |
| 287 return c | 286 return c |
| 288 return 0 | 287 return 0 |
| 289 | 288 |
| 290 logging.critical('Available %s Devices:', self._device_type) | 289 logging.critical('Available %s Devices:', self._device_type) |
| 291 logging.critical( | 290 logging.critical( |
| 292 ' %s %s %s %s %s', | 291 ' %s %s %s %s %s', |
| 293 'OS'.ljust(10), | 292 'OS'.ljust(10), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 324 | 323 |
| 325 @property | 324 @property |
| 326 def device_type_id(self): | 325 def device_type_id(self): |
| 327 return self._device['device_type_id'] | 326 return self._device['device_type_id'] |
| 328 | 327 |
| 329 @property | 328 @property |
| 330 def network_config(self): | 329 def network_config(self): |
| 331 return self._network_config | 330 return self._network_config |
| 332 | 331 |
| 333 @property | 332 @property |
| 334 def only_output_failures(self): | 333 def only_output_failures(self): # pylint: disable=no-self-use |
| 335 # TODO(jbudorick): Remove this once b/18981674 is fixed. | 334 # TODO(jbudorick): Remove this once b/18981674 is fixed. |
| 336 return True | 335 return True |
| 337 | 336 |
| 338 @property | 337 @property |
| 339 def results_path(self): | 338 def results_path(self): |
| 340 return self._results_path | 339 return self._results_path |
| 341 | 340 |
| 342 @property | 341 @property |
| 343 def runner_package(self): | 342 def runner_package(self): |
| 344 return self._runner_package | 343 return self._runner_package |
| (...skipping 14 matching lines...) Expand all Loading... |
| 359 def trigger(self): | 358 def trigger(self): |
| 360 return self._trigger | 359 return self._trigger |
| 361 | 360 |
| 362 @property | 361 @property |
| 363 def verbose_count(self): | 362 def verbose_count(self): |
| 364 return self._verbose_count | 363 return self._verbose_count |
| 365 | 364 |
| 366 @property | 365 @property |
| 367 def device_type(self): | 366 def device_type(self): |
| 368 return self._device_type | 367 return self._device_type |
| OLD | NEW |