Run a command and return the trimmed stdout.
(args: list[str], **kwargs)
| 10 | |
| 11 | |
| 12 | def run_command(args: list[str], **kwargs) -> str: |
| 13 | """Run a command and return the trimmed stdout.""" |
| 14 | res = subprocess.run(args, capture_output=True, **kwargs) |
| 15 | if res.returncode != 0: |
| 16 | stderr = res.stderr.decode(errors="replace") if res.stderr else "" |
| 17 | raise RuntimeError(f"Command {args} exited with {res.returncode}: {stderr}") |
| 18 | return res.stdout.decode().strip() |
| 19 | |
| 20 | |
| 21 | @lru_cache(maxsize=1) |
no outgoing calls
no test coverage detected