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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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() |
193 device.RunShellCommand('date -u %f' % time.time(), as_root=True) | 193 # Need to set env var 'TZ' to 'UTC' so that devices set to UTC time. |
194 os.environ['TZ'] = 'UTC' | |
195 time.tzset() | |
196 device.RunShellCommand('date -s %s' % time.strftime('%Y%m%d.%I%M%S'), | |
jbudorick
2014/10/22 15:52:11
Can you just do time.strftime(..., time.gmtime())
navabi
2014/10/22 16:17:35
Done.
| |
197 as_root=True) | |
194 # TODO(jbudorick): Tune the timeout per OS version. | 198 # TODO(jbudorick): Tune the timeout per OS version. |
195 device.Reboot(True, timeout=600, retries=0) | 199 device.Reboot(True, timeout=600, retries=0) |
196 props = device.RunShellCommand('getprop') | 200 props = device.RunShellCommand('getprop') |
197 for prop in props: | 201 for prop in props: |
198 logging.info(' %s' % prop) | 202 logging.info(' %s' % prop) |
199 if options.auto_reconnect: | 203 if options.auto_reconnect: |
200 PushAndLaunchAdbReboot(device, options.target) | 204 PushAndLaunchAdbReboot(device, options.target) |
201 except (errors.WaitForResponseTimedOutError, | 205 except (errors.WaitForResponseTimedOutError, |
202 device_errors.CommandTimeoutError): | 206 device_errors.CommandTimeoutError): |
203 logging.info('Timed out waiting for device %s. Adding to blacklist.', | 207 logging.info('Timed out waiting for device %s. Adding to blacklist.', |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 | 253 |
250 if args: | 254 if args: |
251 print >> sys.stderr, 'Unused args %s' % args | 255 print >> sys.stderr, 'Unused args %s' % args |
252 return 1 | 256 return 1 |
253 | 257 |
254 return ProvisionDevices(options) | 258 return ProvisionDevices(options) |
255 | 259 |
256 | 260 |
257 if __name__ == '__main__': | 261 if __name__ == '__main__': |
258 sys.exit(main(sys.argv)) | 262 sys.exit(main(sys.argv)) |
OLD | NEW |