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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 class _PHASES(object): | 44 class _PHASES(object): |
45 WIPE = 'wipe' | 45 WIPE = 'wipe' |
46 PROPERTIES = 'properties' | 46 PROPERTIES = 'properties' |
47 FINISH = 'finish' | 47 FINISH = 'finish' |
48 | 48 |
49 ALL = [WIPE, PROPERTIES, FINISH] | 49 ALL = [WIPE, PROPERTIES, FINISH] |
50 | 50 |
51 | 51 |
52 def ProvisionDevices(options): | 52 def ProvisionDevices(options): |
53 if options.device is not None: | 53 devices = device_utils.DeviceUtils.HealthyDevices() |
54 devices = [options.device] | 54 if options.device: |
55 else: | 55 devices = [d for d in devices if d == options.device] |
56 devices = device_utils.DeviceUtils.HealthyDevices() | 56 if not devices: |
| 57 raise device_errors.DeviceUnreachableError(options.device) |
57 | 58 |
58 parallel_devices = device_utils.DeviceUtils.parallel(devices) | 59 parallel_devices = device_utils.DeviceUtils.parallel(devices) |
59 parallel_devices.pMap(ProvisionDevice, options) | 60 parallel_devices.pMap(ProvisionDevice, options) |
60 if options.auto_reconnect: | 61 if options.auto_reconnect: |
61 _LaunchHostHeartbeat() | 62 _LaunchHostHeartbeat() |
62 blacklist = device_blacklist.ReadBlacklist() | 63 blacklist = device_blacklist.ReadBlacklist() |
63 if all(d in blacklist for d in devices): | 64 if all(d in blacklist for d in devices): |
64 raise device_errors.NoDevicesError | 65 raise device_errors.NoDevicesError |
65 return 0 | 66 return 0 |
66 | 67 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 args = parser.parse_args() | 320 args = parser.parse_args() |
320 constants.SetBuildType(args.target) | 321 constants.SetBuildType(args.target) |
321 | 322 |
322 run_tests_helper.SetLogLevel(args.verbose) | 323 run_tests_helper.SetLogLevel(args.verbose) |
323 | 324 |
324 return ProvisionDevices(args) | 325 return ProvisionDevices(args) |
325 | 326 |
326 | 327 |
327 if __name__ == '__main__': | 328 if __name__ == '__main__': |
328 sys.exit(main()) | 329 sys.exit(main()) |
OLD | NEW |