From cbfaf38b9c198e0f523078e3d32437372ceffcf0 Mon Sep 17 00:00:00 2001 From: Leviaria <113382526+Leviaria@users.noreply.github.com> Date: Sun, 30 Jun 2024 20:28:43 +0200 Subject: [PATCH 1/2] Update emulator.py --- clashroyalebuildabot/emulator/emulator.py | 26 +++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/clashroyalebuildabot/emulator/emulator.py b/clashroyalebuildabot/emulator/emulator.py index d6c8b4d..db40da1 100644 --- a/clashroyalebuildabot/emulator/emulator.py +++ b/clashroyalebuildabot/emulator/emulator.py @@ -173,6 +173,7 @@ def _run_command(self, command): command = [ADB_PATH, "-s", self.serial, *command] logger.debug(" ".join(command)) try: + start_time = time.time() result = subprocess.run( command, cwd=EMULATOR_DIR, @@ -180,6 +181,10 @@ def _run_command(self, command): check=True, text=True, ) + end_time = time.time() + logger.debug( + f"Command executed in {end_time - start_time} seconds" + ) except subprocess.CalledProcessError as e: logger.error(f"Error executing command: {e}") logger.error(f"Output: {e.stdout}") @@ -220,13 +225,19 @@ def _start_scrcpy(self): "raw_video_stream=true", f"max_size={self.width}", ] - with subprocess.Popen( - command, - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, - cwd=EMULATOR_DIR, - ) as proc: - self.scrcpy_proc = proc + logger.debug("Starting scrcpy process") + try: + self.scrcpy_proc = subprocess.Popen( + command, + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + cwd=EMULATOR_DIR, + ) + logger.debug("scrcpy process started") + except Exception as e: + logger.error(f"Failed to start scrcpy process: {e}") + self.quit() + raise def _forward_port(self): self._run_command( @@ -266,6 +277,7 @@ def _update_screenshot(self): continue self.frame = frames[-1] + time.sleep(0.001) def _get_width_and_height(self): window_size = self._run_command(["shell", "wm", "size"]) From 614a84d5c26c21869703dd766d40e719492f6e81 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 1 Jul 2024 15:51:33 +0100 Subject: [PATCH 2/2] Ignore pylint with error --- clashroyalebuildabot/emulator/emulator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clashroyalebuildabot/emulator/emulator.py b/clashroyalebuildabot/emulator/emulator.py index db40da1..9efbacd 100644 --- a/clashroyalebuildabot/emulator/emulator.py +++ b/clashroyalebuildabot/emulator/emulator.py @@ -1,3 +1,5 @@ +# pylint: disable=consider-using-with + import atexit from contextlib import contextmanager import os