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 |
32 _SYSTEM_WEBVIEW_PATHS = ['/system/app/webview', '/system/app/WebViewGoogle'] | 37 _SYSTEM_WEBVIEW_PATHS = ['/system/app/webview', '/system/app/WebViewGoogle'] |
33 | 38 |
34 | 39 |
35 class _DEFAULT_TIMEOUTS(object): | 40 class _DEFAULT_TIMEOUTS(object): |
36 # L can take a while to reboot after a wipe. | 41 # L can take a while to reboot after a wipe. |
37 LOLLIPOP = 600 | 42 LOLLIPOP = 600 |
38 PRE_LOLLIPOP = 180 | 43 PRE_LOLLIPOP = 180 |
39 | 44 |
40 HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) | 45 HELP_TEXT = '{}s on L, {}s on pre-L'.format(LOLLIPOP, PRE_LOLLIPOP) |
41 | 46 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 try: | 99 try: |
95 if should_run_phase(_PHASES.WIPE): | 100 if should_run_phase(_PHASES.WIPE): |
96 run_phase(WipeDevice) | 101 run_phase(WipeDevice) |
97 | 102 |
98 if should_run_phase(_PHASES.PROPERTIES): | 103 if should_run_phase(_PHASES.PROPERTIES): |
99 run_phase(SetProperties) | 104 run_phase(SetProperties) |
100 | 105 |
101 if should_run_phase(_PHASES.FINISH): | 106 if should_run_phase(_PHASES.FINISH): |
102 run_phase(FinishProvisioning, reboot=False) | 107 run_phase(FinishProvisioning, reboot=False) |
103 | 108 |
104 except device_errors.CommandTimeoutError: | 109 except (errors.WaitForResponseTimedOutError, |
| 110 device_errors.CommandTimeoutError): |
105 logging.exception('Timed out waiting for device %s. Adding to blacklist.', | 111 logging.exception('Timed out waiting for device %s. Adding to blacklist.', |
106 str(device)) | 112 str(device)) |
107 device_blacklist.ExtendBlacklist([str(device)]) | 113 device_blacklist.ExtendBlacklist([str(device)]) |
108 | 114 |
109 except device_errors.CommandFailedError: | 115 except device_errors.CommandFailedError: |
110 logging.exception('Failed to provision device %s. Adding to blacklist.', | 116 logging.exception('Failed to provision device %s. Adding to blacklist.', |
111 str(device)) | 117 str(device)) |
112 device_blacklist.ExtendBlacklist([str(device)]) | 118 device_blacklist.ExtendBlacklist([str(device)]) |
113 | 119 |
114 | 120 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 args = parser.parse_args() | 357 args = parser.parse_args() |
352 constants.SetBuildType(args.target) | 358 constants.SetBuildType(args.target) |
353 | 359 |
354 run_tests_helper.SetLogLevel(args.verbose) | 360 run_tests_helper.SetLogLevel(args.verbose) |
355 | 361 |
356 return ProvisionDevices(args) | 362 return ProvisionDevices(args) |
357 | 363 |
358 | 364 |
359 if __name__ == '__main__': | 365 if __name__ == '__main__': |
360 sys.exit(main()) | 366 sys.exit(main()) |
OLD | NEW |