From a5a45ca588c04632c3c40e64130b292b2da6a20b Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Fri, 15 Nov 2024 17:00:38 -0800 Subject: [PATCH 1/5] Update tools/python/util/android/android.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/python/util/android/android.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/python/util/android/android.py b/tools/python/util/android/android.py index 23897a36241c6..a50f894b3525c 100644 --- a/tools/python/util/android/android.py +++ b/tools/python/util/android/android.py @@ -110,7 +110,8 @@ def start_emulator( ) -> subprocess.Popen: if is_emulator_running_by_avd(avd_name=avd_name): raise RuntimeError( - f"An emulator with avd_name{avd_name} is already running. Please close it before starting a new one.") + f"An emulator with avd_name{avd_name} is already running. Please close it before starting a new one." + ) with contextlib.ExitStack() as emulator_stack, contextlib.ExitStack() as waiter_stack: emulator_args = [ sdk_tool_paths.emulator, From db94c41d4fccd5a6337f19fa96a479577b848e2a Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Fri, 15 Nov 2024 17:00:49 -0800 Subject: [PATCH 2/5] Update tools/python/util/android/android.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/python/util/android/android.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/python/util/android/android.py b/tools/python/util/android/android.py index a50f894b3525c..528a24b5074af 100644 --- a/tools/python/util/android/android.py +++ b/tools/python/util/android/android.py @@ -215,6 +215,7 @@ def start_emulator( raise RuntimeError("Emulator failed to start.") return emulator_process + def is_emulator_running_by_avd(avd_name: str) -> bool: """ Check if an emulator is running based on the provided AVD name. From 5c5b014fe16aefd7aee91f00bb7d024c758e5e5c Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Fri, 15 Nov 2024 17:01:00 -0800 Subject: [PATCH 3/5] Update tools/python/util/android/android.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/python/util/android/android.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/python/util/android/android.py b/tools/python/util/android/android.py index 528a24b5074af..e767e69e0d284 100644 --- a/tools/python/util/android/android.py +++ b/tools/python/util/android/android.py @@ -237,9 +237,7 @@ def is_emulator_running_by_avd(avd_name: str) -> bool: # Step 2: Check each running emulator's AVD name for emulator in running_emulators: try: - avd_info = subprocess.check_output( - ["adb", "-s", emulator, "emu", "avd", "name"], text=True - ).strip() + avd_info = subprocess.check_output(["adb", "-s", emulator, "emu", "avd", "name"], text=True).strip() if avd_info == avd_name: return True except subprocess.SubprocessError: From a405d62d25a434684a6456877effa2d6b73cf250 Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Fri, 15 Nov 2024 17:01:08 -0800 Subject: [PATCH 4/5] Update tools/python/util/android/android.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/python/util/android/android.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/python/util/android/android.py b/tools/python/util/android/android.py index e767e69e0d284..a6f2235c3d56b 100644 --- a/tools/python/util/android/android.py +++ b/tools/python/util/android/android.py @@ -283,8 +283,7 @@ def stop_emulator_by_proc(emulator_proc: subprocess.Popen, timeout: int = 120): while is_emulator_running_by_proc(emulator_proc): if datetime.datetime.now() > end_time: - raise RuntimeError( - f"Failed to stop the emulator within the specified timeout = {timeout} seconds.") + raise RuntimeError(f"Failed to stop the emulator within the specified timeout = {timeout} seconds.") _log.debug("Emulator still running. Checking again in 5 seconds...") time.sleep(interval) From b9ea99c47ad082862f021007c69425e7d144c977 Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Fri, 15 Nov 2024 17:01:15 -0800 Subject: [PATCH 5/5] Update tools/python/util/android/android.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- tools/python/util/android/android.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/python/util/android/android.py b/tools/python/util/android/android.py index a6f2235c3d56b..e43e13eaf7d2c 100644 --- a/tools/python/util/android/android.py +++ b/tools/python/util/android/android.py @@ -310,7 +310,8 @@ def stop_emulator_by_pid(emulator_pid: int, timeout: int = 120): while is_emulator_running_by_pid(emulator_pid): if datetime.datetime.now() > end_time: raise RuntimeError( - f"Failed to stop the emulator with PID {emulator_pid} within the specified timeout = {timeout} seconds.") + f"Failed to stop the emulator with PID {emulator_pid} within the specified timeout = {timeout} seconds." + ) _log.debug("Emulator still running. Checking again in 5 seconds...") time.sleep(interval)