X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=exec_utils.py;h=1b587405fb1a706a1d7b1c128fde2ad878401137;hb=1fa049c0ce2af2027e362e368321636c75c987de;hp=0ed360191d6ad9f89c64acf591f78044008f4009;hpb=497fb9e21f45ec08e1486abaee6dfa7b20b8a691;p=python_utils.git diff --git a/exec_utils.py b/exec_utils.py index 0ed3601..1b58740 100644 --- a/exec_utils.py +++ b/exec_utils.py @@ -2,10 +2,10 @@ import shlex import subprocess -from typing import List +from typing import List, Optional -def cmd_with_timeout(command: str, timeout_seconds: float) -> int: +def cmd_with_timeout(command: str, timeout_seconds: Optional[float]) -> int: return subprocess.check_call( ["/bin/bash", "-c", command], timeout=timeout_seconds ) @@ -25,12 +25,14 @@ def run_silently(command: str) -> None: """Run a command silently but raise subprocess.CalledProcessError if it fails.""" subprocess.run( - command, shell=True, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, - capture_output=False, check=True + command, shell=True, stderr=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, capture_output=False, check=True ) -def cmd_in_background(command: str, *, silent: bool = False) -> subprocess.Popen: +def cmd_in_background( + command: str, *, silent: bool = False +) -> subprocess.Popen: args = shlex.split(command) if silent: return subprocess.Popen(args,