(*cmd: str, retcode: int | None = 0, **kwargs: Any)
| 14 | |
| 15 | |
| 16 | def cmd_output(*cmd: str, retcode: int | None = 0, **kwargs: Any) -> str: |
| 17 | kwargs.setdefault('stdout', subprocess.PIPE) |
| 18 | kwargs.setdefault('stderr', subprocess.PIPE) |
| 19 | proc = subprocess.Popen(cmd, **kwargs) |
| 20 | stdout, stderr = proc.communicate() |
| 21 | stdout = stdout.decode() |
| 22 | if retcode is not None and proc.returncode != retcode: |
| 23 | raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr) |
| 24 | return stdout |
| 25 | |
| 26 | |
| 27 | def zsplit(s: str) -> list[str]: |