Index: build/android/provision_devices.py |
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py |
index 8890fc0df2ad77b2b2ac78c6d65fae2d6a903082..11b28625a9ab0df52f74210cdc37dba0c75b13ca 100755 |
--- a/build/android/provision_devices.py |
+++ b/build/android/provision_devices.py |
@@ -35,6 +35,7 @@ from devil.android import device_temp_file |
from devil.android import device_utils |
from devil.android.sdk import keyevent |
from devil.android.sdk import version_codes |
+from devil.constants import exit_codes |
from devil.utils import run_tests_helper |
from devil.utils import timeout_retry |
from pylib import constants |
@@ -370,16 +371,21 @@ def FinishProvisioning(device, options): |
if device.build_version_sdk >= version_codes.MARSHMALLOW: |
date_format = '%m%d%H%M%Y.%S' |
set_date_command = ['date', '-u'] |
+ get_date_command = ['date', '-u'] |
else: |
date_format = '%Y%m%d.%H%M%S' |
- set_date_command = ['date', '-u', '-s'] |
+ set_date_command = ['date', '-s'] |
+ get_date_command = ['date'] |
+ |
+ # TODO(jbudorick): This is wrong on pre-M devices -- get/set are |
+ # dealing in local time, but we're setting based on GMT. |
strgmtime = time.strftime(date_format, time.gmtime()) |
set_date_command.append(strgmtime) |
device.RunShellCommand(set_date_command, as_root=True, check_return=True) |
+ get_date_command.append('+"%Y%m%d.%H%M%S"') |
device_time = device.RunShellCommand( |
- ['date', '-u', '+"%Y%m%d.%H%M%S"'], as_root=True, |
- single_line=True).replace('"', '') |
+ get_date_command, as_root=True, single_line=True).replace('"', '') |
device_time = datetime.datetime.strptime(device_time, "%Y%m%d.%H%M%S") |
correct_time = datetime.datetime.strptime(strgmtime, date_format) |
tdelta = (correct_time - device_time).seconds |
@@ -549,7 +555,10 @@ def main(): |
devil_chromium.Initialize(custom_deps=devil_custom_deps) |
- return ProvisionDevices(args) |
+ try: |
+ return ProvisionDevices(args) |
+ except (device_errors.DeviceUnreachableError, device_errors.NoDevicesError): |
+ return exit_codes.INFRA |
if __name__ == '__main__': |