From 3a18895c6facd86b97d8cd0b955a2ab61f02cde4 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Tue, 13 Apr 2021 12:44:45 -0400 Subject: Add 5s timeout to cleanup commands Sometimes shutdown takes a while due to adb issues, gracefully terminate with a timeout. This will throw an exception if timeout occured, telling the developer that something went wrong. Test: python3 update_device.py ota.zip Change-Id: I44edc6a291fc682b9439ab97f2880d47dc4e457b --- scripts/update_device.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/update_device.py') diff --git a/scripts/update_device.py b/scripts/update_device.py index b784b1bc..3ce40a55 100755 --- a/scripts/update_device.py +++ b/scripts/update_device.py @@ -350,7 +350,7 @@ class AdbHost(object): if self._device_serial: self._command_prefix += ['-s', self._device_serial] - def adb(self, command): + def adb(self, command, timeout_seconds: float = None): """Run an ADB command like "adb push". Args: @@ -365,7 +365,7 @@ class AdbHost(object): command = self._command_prefix + command logging.info('Running: %s', ' '.join(str(x) for x in command)) p = subprocess.Popen(command, universal_newlines=True) - p.wait() + p.wait(timeout_seconds) return p.returncode def adb_output(self, command): @@ -546,7 +546,7 @@ def main(): if server_thread: server_thread.StopServer() for cmd in finalize_cmds: - dut.adb(cmd) + dut.adb(cmd, 5) return 0 -- cgit v1.2.3 From ffd2144ccd4378a76bc797a113f4eb36ca275634 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Wed, 14 Apr 2021 09:09:41 -0400 Subject: Rename no-care-map flag Since other flags use - instead of _, keep no-care-map flag consistent Test: th Change-Id: Ibf981ecbf7b3804e20c52ef1de8f55732cbe6295 --- scripts/update_device.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/update_device.py') diff --git a/scripts/update_device.py b/scripts/update_device.py index 3ce40a55..7313d7c3 100755 --- a/scripts/update_device.py +++ b/scripts/update_device.py @@ -430,12 +430,12 @@ def main(): help='Do not perform slot switch after the update.') parser.add_argument('--no-postinstall', action='store_true', help='Do not execute postinstall scripts after the update.') - parser.add_argument('--allocate_only', action='store_true', + parser.add_argument('--allocate-only', action='store_true', help='Allocate space for this OTA, instead of actually \ applying the OTA.') - parser.add_argument('--verify_only', action='store_true', + parser.add_argument('--verify-only', action='store_true', help='Verify metadata then exit, instead of applying the OTA.') - parser.add_argument('--no_care_map', action='store_true', + parser.add_argument('--no-care-map', action='store_true', help='Do not push care_map.pb to device.') args = parser.parse_args() logging.basicConfig( @@ -486,7 +486,7 @@ def main(): care_map_fp.write(zfp.read(CARE_MAP_ENTRY_NAME)) care_map_fp.flush() dut.adb(["push", care_map_fp.name, - "/data/ota_package/" + CARE_MAP_ENTRY_NAME]) + "/data/ota_package/" + CARE_MAP_ENTRY_NAME]) if args.file: # Update via pushing a file to /data. -- cgit v1.2.3 From 0c71550bf36a8d1590486e480fe2deb7253664cb Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 19 Apr 2021 13:48:21 -0700 Subject: Update shebang line for update_device.py. It is no longer python2 compatible. Test: pass Change-Id: Ibb0b7aa33ba1be3e2f40893da70f81c858479f7e --- scripts/update_device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/update_device.py') diff --git a/scripts/update_device.py b/scripts/update_device.py index 7313d7c3..f672cda0 100755 --- a/scripts/update_device.py +++ b/scripts/update_device.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) 2017 The Android Open Source Project # -- cgit v1.2.3