Chromium Code Reviews| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 logging.info("Version name for %s is %s", package, version_name) | 125 logging.info("Version name for %s is %s", package, version_name) |
| 126 | 126 |
| 127 CheckExternalStorage(device) | 127 CheckExternalStorage(device) |
| 128 | 128 |
| 129 except device_errors.CommandTimeoutError: | 129 except device_errors.CommandTimeoutError: |
| 130 logging.exception('Timed out waiting for device %s. Adding to blacklist.', | 130 logging.exception('Timed out waiting for device %s. Adding to blacklist.', |
| 131 str(device)) | 131 str(device)) |
| 132 if blacklist: | 132 if blacklist: |
| 133 blacklist.Extend([str(device)], reason='provision_timeout') | 133 blacklist.Extend([str(device)], reason='provision_timeout') |
| 134 | 134 |
| 135 except device_errors.CommandFailedError: | 135 except device_errors.CommandFailedError: |
|
jbudorick
2016/02/05 01:40:43
Not catching the exception below will result in th
rnephew (Reviews Here)
2016/02/05 01:52:00
Acknowledged.
| |
| 136 logging.exception('Failed to provision device %s. Adding to blacklist.', | 136 logging.exception('Failed to provision device %s. Adding to blacklist.', |
| 137 str(device)) | 137 str(device)) |
| 138 if blacklist: | 138 if blacklist: |
| 139 blacklist.Extend([str(device)], reason='provision_failure') | 139 blacklist.Extend([str(device)], reason='provision_failure') |
| 140 | 140 |
| 141 def CheckExternalStorage(device): | 141 def CheckExternalStorage(device): |
| 142 """Checks that storage is writable and if not makes it writable. | 142 """Checks that storage is writable and if not makes it writable. |
| 143 | 143 |
| 144 Arguments: | 144 Arguments: |
| 145 device: The device to check. | 145 device: The device to check. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 | 331 |
| 332 def FinishProvisioning(device, options): | 332 def FinishProvisioning(device, options): |
| 333 # The lockscreen can't be disabled on user builds, so send a keyevent | 333 # The lockscreen can't be disabled on user builds, so send a keyevent |
| 334 # to unlock it. | 334 # to unlock it. |
| 335 if device.IsUserBuild(): | 335 if device.IsUserBuild(): |
| 336 device.SendKeyEvent(keyevent.KEYCODE_MENU) | 336 device.SendKeyEvent(keyevent.KEYCODE_MENU) |
| 337 | 337 |
| 338 if options.min_battery_level is not None: | 338 if options.min_battery_level is not None: |
| 339 try: | 339 try: |
| 340 battery = battery_utils.BatteryUtils(device) | 340 battery = battery_utils.BatteryUtils(device) |
| 341 battery.ChargeDeviceToLevel(options.min_battery_level) | 341 try: |
| 342 battery.ChargeDeviceToLevel(options.min_battery_level) | |
| 343 except device_errors.DeviceChargingError: | |
| 344 device.Reboot() | |
| 345 try: | |
| 346 battery.ChargeDeviceToLevel(options.min_battery_level) | |
| 347 except device_errors.DeviceChargingError: | |
|
jbudorick
2016/02/05 01:40:43
We shouldn't catch this or handle the blacklist he
rnephew (Reviews Here)
2016/02/05 01:52:00
Done.
| |
| 348 blacklist = device_blacklist.Blacklist(options.blacklist_file) | |
| 349 blacklist.Extend([str(device)], reason='Charging timeout') | |
| 350 logging.exception('Error while charging device.') | |
| 342 except device_errors.CommandFailedError: | 351 except device_errors.CommandFailedError: |
|
jbudorick
2016/02/05 01:40:43
We shouldn't catch this either.
rnephew (Reviews Here)
2016/02/05 01:52:00
Done.
| |
| 343 logging.exception('Unable to charge device to specified level.') | 352 logging.exception('Unable to charge device to specified level.') |
| 344 | 353 |
| 345 if options.max_battery_temp is not None: | 354 if options.max_battery_temp is not None: |
| 346 try: | 355 try: |
| 347 battery = battery_utils.BatteryUtils(device) | 356 battery = battery_utils.BatteryUtils(device) |
| 348 battery.LetBatteryCoolToTemperature(options.max_battery_temp) | 357 battery.LetBatteryCoolToTemperature(options.max_battery_temp) |
| 349 except device_errors.CommandFailedError: | 358 except device_errors.CommandFailedError: |
| 350 logging.exception('Unable to let battery cool to specified temperature.') | 359 logging.exception('Unable to let battery cool to specified temperature.') |
| 351 | 360 |
| 352 def _set_and_verify_date(): | 361 def _set_and_verify_date(): |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 }, | 539 }, |
| 531 } | 540 } |
| 532 | 541 |
| 533 devil_chromium.Initialize(custom_deps=devil_custom_deps) | 542 devil_chromium.Initialize(custom_deps=devil_custom_deps) |
| 534 | 543 |
| 535 return ProvisionDevices(args) | 544 return ProvisionDevices(args) |
| 536 | 545 |
| 537 | 546 |
| 538 if __name__ == '__main__': | 547 if __name__ == '__main__': |
| 539 sys.exit(main()) | 548 sys.exit(main()) |
| OLD | NEW |