X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=exec_utils.py;h=b52f52f0dc785033fc437a638c734d79cf8d5aa8;hb=b29be4f1750fd20bd2eada88e751dfae85817882;hp=89cfbd7bf15f23a7a0effaed24954f7b4480aded;hpb=2c54bfde335f3631f045a871c540c9d63c5bb081;p=python_utils.git 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.