diff options
| author | Scott <[email protected]> | 2021-12-04 21:23:11 -0800 |
|---|---|---|
| committer | Scott <[email protected]> | 2021-12-04 21:23:11 -0800 |
| commit | b29be4f1750fd20bd2eada88e751dfae85817882 (patch) | |
| tree | d776c05519505fa3234ed44ae952163f0853e88c /exec_utils.py | |
| parent | ed8fa2b10b0177b15b7423263bdd390efde2f0c8 (diff) | |
Various changes.
Diffstat (limited to 'exec_utils.py')
| -rw-r--r-- | exec_utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/exec_utils.py b/exec_utils.py index 89cfbd7..b52f52f 100644 --- a/exec_utils.py +++ b/exec_utils.py @@ -10,6 +10,20 @@ from typing import List, Optional logger = logging.getLogger(__file__) +def cmd_showing_output(command: str) -> None: + p = subprocess.Popen( + command, + shell=True, + bufsize=0, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + for line in iter(p.stdout.readline, b''): + print(line.decode('utf-8'), end='') + p.stdout.close() + p.wait() + + def cmd_with_timeout(command: str, timeout_seconds: Optional[float]) -> int: """ Run a command but do not let it run for more than timeout seconds. |
