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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 device_time = device.RunShellCommand( | 312 device_time = device.RunShellCommand( |
313 ['date', '+"%Y%m%d.%H%M%S"'], as_root=True, | 313 ['date', '+"%Y%m%d.%H%M%S"'], as_root=True, |
314 single_line=True).replace('"', '') | 314 single_line=True).replace('"', '') |
315 device_time = datetime.datetime.strptime(device_time, "%Y%m%d.%H%M%S") | 315 device_time = datetime.datetime.strptime(device_time, "%Y%m%d.%H%M%S") |
316 correct_time = datetime.datetime.strptime(strgmtime, date_format) | 316 correct_time = datetime.datetime.strptime(strgmtime, date_format) |
317 tdelta = (correct_time - device_time).seconds | 317 tdelta = (correct_time - device_time).seconds |
318 if tdelta <= 1: | 318 if tdelta <= 1: |
319 logging.info('Date/time successfully set on %s', device) | 319 logging.info('Date/time successfully set on %s', device) |
320 return True | 320 return True |
321 else: | 321 else: |
| 322 logging.error('Date mismatch. Device: %s Correct: %s', |
| 323 device_time.isoformat(), correct_time.isoformat()) |
322 return False | 324 return False |
323 | 325 |
324 # Sometimes the date is not set correctly on the devices. Retry on failure. | 326 # Sometimes the date is not set correctly on the devices. Retry on failure. |
325 if not timeout_retry.WaitFor(_set_and_verify_date, wait_period=1, | 327 if not timeout_retry.WaitFor(_set_and_verify_date, wait_period=1, |
326 max_tries=2): | 328 max_tries=2): |
327 raise device_errors.CommandFailedError( | 329 raise device_errors.CommandFailedError( |
328 'Failed to set date & time.', device_serial=str(device)) | 330 'Failed to set date & time.', device_serial=str(device)) |
329 | 331 |
330 props = device.RunShellCommand('getprop', check_return=True) | 332 props = device.RunShellCommand('getprop', check_return=True) |
331 for prop in props: | 333 for prop in props: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 args = parser.parse_args() | 452 args = parser.parse_args() |
451 constants.SetBuildType(args.target) | 453 constants.SetBuildType(args.target) |
452 | 454 |
453 run_tests_helper.SetLogLevel(args.verbose) | 455 run_tests_helper.SetLogLevel(args.verbose) |
454 | 456 |
455 return ProvisionDevices(args) | 457 return ProvisionDevices(args) |
456 | 458 |
457 | 459 |
458 if __name__ == '__main__': | 460 if __name__ == '__main__': |
459 sys.exit(main()) | 461 sys.exit(main()) |
OLD | NEW |