| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 class _PHASES(object): | 47 class _PHASES(object): |
| 48 WIPE = 'wipe' | 48 WIPE = 'wipe' |
| 49 PROPERTIES = 'properties' | 49 PROPERTIES = 'properties' |
| 50 FINISH = 'finish' | 50 FINISH = 'finish' |
| 51 | 51 |
| 52 ALL = [WIPE, PROPERTIES, FINISH] | 52 ALL = [WIPE, PROPERTIES, FINISH] |
| 53 | 53 |
| 54 | 54 |
| 55 def ProvisionDevices(args): | 55 def ProvisionDevices(args): |
| 56 if args.blacklist_file: | 56 blacklist = (device_blacklist.Blacklist(args.blacklist_file) |
| 57 blacklist = device_blacklist.Blacklist(args.blacklist_file) | 57 if args.blacklist_file |
| 58 else: | 58 else None) |
| 59 # TODO(jbudorick): Remove once the bots have switched over. | |
| 60 blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) | |
| 61 | 59 |
| 62 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 60 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
| 63 if args.device: | 61 if args.device: |
| 64 devices = [d for d in devices if d == args.device] | 62 devices = [d for d in devices if d == args.device] |
| 65 if not devices: | 63 if not devices: |
| 66 raise device_errors.DeviceUnreachableError(args.device) | 64 raise device_errors.DeviceUnreachableError(args.device) |
| 67 | 65 |
| 68 parallel_devices = device_utils.DeviceUtils.parallel(devices) | 66 parallel_devices = device_utils.DeviceUtils.parallel(devices) |
| 69 parallel_devices.pMap(ProvisionDevice, blacklist, args) | 67 parallel_devices.pMap(ProvisionDevice, blacklist, args) |
| 70 if args.auto_reconnect: | 68 if args.auto_reconnect: |
| 71 _LaunchHostHeartbeat() | 69 _LaunchHostHeartbeat() |
| 72 blacklisted_devices = blacklist.Read() | 70 blacklisted_devices = blacklist.Read() if blacklist else [] |
| 73 if args.output_device_blacklist: | 71 if args.output_device_blacklist: |
| 74 with open(args.output_device_blacklist, 'w') as f: | 72 with open(args.output_device_blacklist, 'w') as f: |
| 75 json.dump(blacklisted_devices, f) | 73 json.dump(blacklisted_devices, f) |
| 76 if all(d in blacklisted_devices for d in devices): | 74 if all(d in blacklisted_devices for d in devices): |
| 77 raise device_errors.NoDevicesError | 75 raise device_errors.NoDevicesError |
| 78 return 0 | 76 return 0 |
| 79 | 77 |
| 80 | 78 |
| 81 def ProvisionDevice(device, blacklist, options): | 79 def ProvisionDevice(device, blacklist, options): |
| 82 if options.reboot_timeout: | 80 if options.reboot_timeout: |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 args = parser.parse_args() | 448 args = parser.parse_args() |
| 451 constants.SetBuildType(args.target) | 449 constants.SetBuildType(args.target) |
| 452 | 450 |
| 453 run_tests_helper.SetLogLevel(args.verbose) | 451 run_tests_helper.SetLogLevel(args.verbose) |
| 454 | 452 |
| 455 return ProvisionDevices(args) | 453 return ProvisionDevices(args) |
| 456 | 454 |
| 457 | 455 |
| 458 if __name__ == '__main__': | 456 if __name__ == '__main__': |
| 459 sys.exit(main()) | 457 sys.exit(main()) |
| OLD | NEW |