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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 if options.max_battery_temp is not None: | 362 if options.max_battery_temp is not None: |
| 363 try: | 363 try: |
| 364 battery = battery_utils.BatteryUtils(device) | 364 battery = battery_utils.BatteryUtils(device) |
| 365 battery.LetBatteryCoolToTemperature(options.max_battery_temp) | 365 battery.LetBatteryCoolToTemperature(options.max_battery_temp) |
| 366 except device_errors.CommandFailedError: | 366 except device_errors.CommandFailedError: |
| 367 logging.exception('Unable to let battery cool to specified temperature.') | 367 logging.exception('Unable to let battery cool to specified temperature.') |
| 368 | 368 |
| 369 def _set_and_verify_date(): | 369 def _set_and_verify_date(): |
| 370 if device.build_version_sdk >= version_codes.MARSHMALLOW: | 370 if device.build_version_sdk >= version_codes.MARSHMALLOW: |
| 371 date_format = '%m%d%H%M%Y.%S' | 371 date_format = '%m%d%H%M%Y.%S' |
| 372 set_date_command = ['date'] | 372 set_date_command = ['date', '-u'] |
|
ghost stip (do not use)
2016/05/13 20:32:48
do we need to mirror this logic in https://goto.go
| |
| 373 else: | 373 else: |
| 374 date_format = '%Y%m%d.%H%M%S' | 374 date_format = '%Y%m%d.%H%M%S' |
| 375 set_date_command = ['date', '-s'] | 375 set_date_command = ['date', '-u', '-s'] |
| 376 strgmtime = time.strftime(date_format, time.gmtime()) | 376 strgmtime = time.strftime(date_format, time.gmtime()) |
| 377 set_date_command.append(strgmtime) | 377 set_date_command.append(strgmtime) |
| 378 device.RunShellCommand(set_date_command, as_root=True, check_return=True) | 378 device.RunShellCommand(set_date_command, as_root=True, check_return=True) |
| 379 | 379 |
| 380 device_time = device.RunShellCommand( | 380 device_time = device.RunShellCommand( |
| 381 ['date', '+"%Y%m%d.%H%M%S"'], as_root=True, | 381 ['date', '-u', '+"%Y%m%d.%H%M%S"'], as_root=True, |
| 382 single_line=True).replace('"', '') | 382 single_line=True).replace('"', '') |
| 383 device_time = datetime.datetime.strptime(device_time, "%Y%m%d.%H%M%S") | 383 device_time = datetime.datetime.strptime(device_time, "%Y%m%d.%H%M%S") |
| 384 correct_time = datetime.datetime.strptime(strgmtime, date_format) | 384 correct_time = datetime.datetime.strptime(strgmtime, date_format) |
| 385 tdelta = (correct_time - device_time).seconds | 385 tdelta = (correct_time - device_time).seconds |
| 386 if tdelta <= 1: | 386 if tdelta <= 1: |
| 387 logging.info('Date/time successfully set on %s', device) | 387 logging.info('Date/time successfully set on %s', device) |
| 388 return True | 388 return True |
| 389 else: | 389 else: |
| 390 logging.error('Date mismatch. Device: %s Correct: %s', | 390 logging.error('Date mismatch. Device: %s Correct: %s', |
| 391 device_time.isoformat(), correct_time.isoformat()) | 391 device_time.isoformat(), correct_time.isoformat()) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 }, | 547 }, |
| 548 } | 548 } |
| 549 | 549 |
| 550 devil_chromium.Initialize(custom_deps=devil_custom_deps) | 550 devil_chromium.Initialize(custom_deps=devil_custom_deps) |
| 551 | 551 |
| 552 return ProvisionDevices(args) | 552 return ProvisionDevices(args) |
| 553 | 553 |
| 554 | 554 |
| 555 if __name__ == '__main__': | 555 if __name__ == '__main__': |
| 556 sys.exit(main()) | 556 sys.exit(main()) |
| OLD | NEW |