| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Provisions Android devices with settings required for bots. | 7 """Provisions Android devices with settings required for bots. |
| 8 | 8 |
| 9 Usage: | 9 Usage: |
| 10 ./provision_devices.py [-d <device serial number>] | 10 ./provision_devices.py [-d <device serial number>] |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 from pylib import constants | 23 from pylib import constants |
| 24 from pylib import device_settings | 24 from pylib import device_settings |
| 25 from pylib.device import battery_utils | 25 from pylib.device import battery_utils |
| 26 from pylib.device import device_blacklist | 26 from pylib.device import device_blacklist |
| 27 from pylib.device import device_errors | 27 from pylib.device import device_errors |
| 28 from pylib.device import device_utils | 28 from pylib.device import device_utils |
| 29 from pylib.utils import run_tests_helper | 29 from pylib.utils import run_tests_helper |
| 30 from pylib.utils import timeout_retry | 30 from pylib.utils import timeout_retry |
| 31 | 31 |
| 32 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, | |
| 33 'third_party', 'android_testrunner')) | |
| 34 import errors | |
| 35 | |
| 36 | |
| 37 _SYSTEM_WEBVIEW_PATHS = ['/system/app/webview', '/system/app/WebViewGoogle'] | 32 _SYSTEM_WEBVIEW_PATHS = ['/system/app/webview', '/system/app/WebViewGoogle'] |
| 38 | 33 |
| 39 | 34 |
| 40 class _DEFAULT_TIMEOUTS(object): | 35 class _DEFAULT_TIMEOUTS(object): |
| 41 # L can take a while to reboot after a wipe. | 36 # L can take a while to reboot after a wipe. |
| 42 LOLLIPOP = 600 | 37 LOLLIPOP = 600 |
| 43 PRE_LOLLIPOP = 180 | 38 PRE_LOLLIPOP = 180 |
| 44 | 39 |
| 45 HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) | 40 HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) |
| 46 | 41 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 try: | 94 try: |
| 100 if should_run_phase(_PHASES.WIPE): | 95 if should_run_phase(_PHASES.WIPE): |
| 101 run_phase(WipeDevice) | 96 run_phase(WipeDevice) |
| 102 | 97 |
| 103 if should_run_phase(_PHASES.PROPERTIES): | 98 if should_run_phase(_PHASES.PROPERTIES): |
| 104 run_phase(SetProperties) | 99 run_phase(SetProperties) |
| 105 | 100 |
| 106 if should_run_phase(_PHASES.FINISH): | 101 if should_run_phase(_PHASES.FINISH): |
| 107 run_phase(FinishProvisioning, reboot=False) | 102 run_phase(FinishProvisioning, reboot=False) |
| 108 | 103 |
| 109 except (errors.WaitForResponseTimedOutError, | 104 except device_errors.CommandTimeoutError: |
| 110 device_errors.CommandTimeoutError): | |
| 111 logging.exception('Timed out waiting for device %s. Adding to blacklist.', | 105 logging.exception('Timed out waiting for device %s. Adding to blacklist.', |
| 112 str(device)) | 106 str(device)) |
| 113 device_blacklist.ExtendBlacklist([str(device)]) | 107 device_blacklist.ExtendBlacklist([str(device)]) |
| 114 | 108 |
| 115 except device_errors.CommandFailedError: | 109 except device_errors.CommandFailedError: |
| 116 logging.exception('Failed to provision device %s. Adding to blacklist.', | 110 logging.exception('Failed to provision device %s. Adding to blacklist.', |
| 117 str(device)) | 111 str(device)) |
| 118 device_blacklist.ExtendBlacklist([str(device)]) | 112 device_blacklist.ExtendBlacklist([str(device)]) |
| 119 | 113 |
| 120 | 114 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 args = parser.parse_args() | 351 args = parser.parse_args() |
| 358 constants.SetBuildType(args.target) | 352 constants.SetBuildType(args.target) |
| 359 | 353 |
| 360 run_tests_helper.SetLogLevel(args.verbose) | 354 run_tests_helper.SetLogLevel(args.verbose) |
| 361 | 355 |
| 362 return ProvisionDevices(args) | 356 return ProvisionDevices(args) |
| 363 | 357 |
| 364 | 358 |
| 365 if __name__ == '__main__': | 359 if __name__ == '__main__': |
| 366 sys.exit(main()) | 360 sys.exit(main()) |
| OLD | NEW |