From 250554b81833ae533c2aca963ac42483a8c8fd41 Mon Sep 17 00:00:00 2001 From: Dominik Klotz <105296959+programminx-askui@users.noreply.github.com> Date: Tue, 10 Jun 2025 23:14:51 +0200 Subject: [PATCH 1/2] fix(PynputAgentOs): Fix missing run_command --- src/askui/tools/pynput/pynput_agent_os.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/askui/tools/pynput/pynput_agent_os.py b/src/askui/tools/pynput/pynput_agent_os.py index c6a28f89..57216dbb 100644 --- a/src/askui/tools/pynput/pynput_agent_os.py +++ b/src/askui/tools/pynput/pynput_agent_os.py @@ -1,6 +1,8 @@ import ctypes import platform import queue +import shlex +import subprocess import time from functools import wraps from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, cast @@ -348,6 +350,10 @@ def set_display(self, display: int = 1) -> None: raise ValueError(error_msg) self._display = display + @override + def run_command(self, command, timeout_ms=30000): + subprocess.run(shlex.split(command)) + def _on_mouse_click( self, x: float, y: float, button: Button, pressed: bool, injected: bool ) -> None: From 9e35ada89aaa2389929a0a8969f99bc11eb88dcb Mon Sep 17 00:00:00 2001 From: onur-askui <210008309+onur-askui@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:42:57 +0200 Subject: [PATCH 2/2] fix(PynputAgentOs): add timeout and type hints to `run_command` --- src/askui/tools/pynput/pynput_agent_os.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/askui/tools/pynput/pynput_agent_os.py b/src/askui/tools/pynput/pynput_agent_os.py index 57216dbb..bccded71 100644 --- a/src/askui/tools/pynput/pynput_agent_os.py +++ b/src/askui/tools/pynput/pynput_agent_os.py @@ -351,8 +351,20 @@ def set_display(self, display: int = 1) -> None: self._display = display @override - def run_command(self, command, timeout_ms=30000): - subprocess.run(shlex.split(command)) + def run_command(self, command: str, timeout_ms: int = 30000) -> None: + """ + Run a shell command. + + Args: + command (str): The command to run. + timeout_ms (int, optional): Timeout in milliseconds. Defaults to 30000. + + Raises: + subprocess.TimeoutExpired: If the command takes longer than the timeout. + subprocess.CalledProcessError: If the command returns a non-zero exit code. + """ + + subprocess.run(shlex.split(command), timeout=timeout_ms / 1000) def _on_mouse_click( self, x: float, y: float, button: Button, pressed: bool, injected: bool