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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 # Some perf bots run benchmarks with USB charging disabled which leads | 172 # Some perf bots run benchmarks with USB charging disabled which leads |
173 # to gradual draining of the battery. We must wait for a full charge | 173 # to gradual draining of the battery. We must wait for a full charge |
174 # before starting a run in order to keep the devices online. | 174 # before starting a run in order to keep the devices online. |
175 try: | 175 try: |
176 battery_info = device.old_interface.GetBatteryInfo() | 176 battery_info = device.old_interface.GetBatteryInfo() |
177 except Exception as e: | 177 except Exception as e: |
178 battery_info = {} | 178 battery_info = {} |
179 logging.error('Unable to obtain battery info for %s, %s', | 179 logging.error('Unable to obtain battery info for %s, %s', |
180 str(device), e) | 180 str(device), e) |
181 | 181 |
182 while int(battery_info.get('level', 100)) < 95: | 182 while int(battery_info.get('level', 100)) < options.min_battery_level: |
183 if not device.old_interface.IsDeviceCharging(): | 183 if not device.old_interface.IsDeviceCharging(): |
184 if device.old_interface.CanControlUsbCharging(): | 184 if device.old_interface.CanControlUsbCharging(): |
185 device.old_interface.EnableUsbCharging() | 185 device.old_interface.EnableUsbCharging() |
186 else: | 186 else: |
187 logging.error('Device is not charging') | 187 logging.error('Device is not charging') |
188 break | 188 break |
189 logging.info('Waiting for device to charge. Current level=%s', | 189 logging.info('Waiting for device to charge. Current level=%s', |
190 battery_info.get('level', 0)) | 190 battery_info.get('level', 0)) |
191 time.sleep(60) | 191 time.sleep(60) |
192 battery_info = device.old_interface.GetBatteryInfo() | 192 battery_info = device.old_interface.GetBatteryInfo() |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 return 0 | 230 return 0 |
231 | 231 |
232 | 232 |
233 def main(argv): | 233 def main(argv): |
234 custom_handler = logging.StreamHandler(sys.stdout) | 234 custom_handler = logging.StreamHandler(sys.stdout) |
235 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) | 235 custom_handler.setFormatter(run_tests_helper.CustomFormatter()) |
236 logging.getLogger().addHandler(custom_handler) | 236 logging.getLogger().addHandler(custom_handler) |
237 logging.getLogger().setLevel(logging.INFO) | 237 logging.getLogger().setLevel(logging.INFO) |
238 | 238 |
239 parser = optparse.OptionParser() | 239 parser = optparse.OptionParser() |
| 240 parser.add_option('--min-battery-level', default=95, type='int', |
| 241 help="Minimum battery level for performance testing " |
| 242 "(default: 95).") |
240 parser.add_option('--skip-wipe', action='store_true', default=False, | 243 parser.add_option('--skip-wipe', action='store_true', default=False, |
241 help="Don't wipe device data during provisioning.") | 244 help="Don't wipe device data during provisioning.") |
242 parser.add_option('--disable-location', action='store_true', default=False, | 245 parser.add_option('--disable-location', action='store_true', default=False, |
243 help="Disallow Google location services on devices.") | 246 help="Disallow Google location services on devices.") |
244 parser.add_option('-d', '--device', | 247 parser.add_option('-d', '--device', |
245 help='The serial number of the device to be provisioned') | 248 help='The serial number of the device to be provisioned') |
246 parser.add_option('-t', '--target', default='Debug', help='The build target') | 249 parser.add_option('-t', '--target', default='Debug', help='The build target') |
247 parser.add_option( | 250 parser.add_option( |
248 '-r', '--auto-reconnect', action='store_true', | 251 '-r', '--auto-reconnect', action='store_true', |
249 help='Push binary which will reboot the device on adb disconnections.') | 252 help='Push binary which will reboot the device on adb disconnections.') |
250 options, args = parser.parse_args(argv[1:]) | 253 options, args = parser.parse_args(argv[1:]) |
251 constants.SetBuildType(options.target) | 254 constants.SetBuildType(options.target) |
252 | 255 |
253 if args: | 256 if args: |
254 print >> sys.stderr, 'Unused args %s' % args | 257 print >> sys.stderr, 'Unused args %s' % args |
255 return 1 | 258 return 1 |
256 | 259 |
257 return ProvisionDevices(options) | 260 return ProvisionDevices(options) |
258 | 261 |
259 | 262 |
260 if __name__ == '__main__': | 263 if __name__ == '__main__': |
261 sys.exit(main(sys.argv)) | 264 sys.exit(main(sys.argv)) |
OLD | NEW |