def cmd_exitcode(command: str, timeout_seconds: Optional[float] = None) -> int:
- """Run a command but do not let it run for more than timeout_seconds.
- This code doesn't capture or rebroadcast the command's output. It
- returns the exit value of the command or raises a TimeoutExpired
- exception if the deadline is exceeded.
+ """Run a command silently and return its exit code once it has
+ finished. If timeout_seconds is provided and the command runs too
+ long it will raise a TimeoutExpired exception.
Args:
command: the command to run
def cmd(command: str, timeout_seconds: Optional[float] = None) -> str:
- """Run a command and capture its output to stdout (only) into a string
- buffer. Return that string as this function's output. Raises
- subprocess.CalledProcessError or TimeoutExpired on error.
+ """Run a command and capture its output to stdout and stderr into a
+ string buffer. Return that string as this function's output.
+ Raises subprocess.CalledProcessError or TimeoutExpired on error.
Args:
command: the command to run
def run_silently(command: str, timeout_seconds: Optional[float] = None) -> None:
"""Run a command silently but raise subprocess.CalledProcessError if
- it fails.
+ it fails and raise a TimeoutExpired if it runs too long.
Args:
command: the command to run