diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-12-13 14:43:54 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-12-13 14:43:54 +0100 |
| commit | 5f6c52dff03f2dc85d5b26b7f4469bc85a25ee09 (patch) | |
| tree | 796cd4b3c710ceb8bdbd44da3d03b47144e641a6 /src/util.py | |
| parent | 3a438c9e0fa878841f4efb3a5eba13d855fdb6cb (diff) | |
| download | allocbench-5f6c52dff03f2dc85d5b26b7f4469bc85a25ee09.tar.gz allocbench-5f6c52dff03f2dc85d5b26b7f4469bc85a25ee09.zip | |
introduce verbosity aware subprocess.run wrapper and use it in benchmarks
Diffstat (limited to 'src/util.py')
| -rw-r--r-- | src/util.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py index 7992084..3f2ab06 100644 --- a/src/util.py +++ b/src/util.py @@ -24,6 +24,32 @@ import sys import src.globalvars +def run_cmd(cmd, + output_verbosity=3, + capture=False, + check=True, + cwd=None, + input=None): + """subprocess.run wrapper which cares about the set verbosity""" + if capture: + stdout = subprocess.PIPE + stderr = stdout + elif src.globalvars.verbosity < output_verbosity: + stdout = subprocess.DEVNULL + stderr = stdout + else: + stdout = None + stderr = stdout + + return subprocess.run(cmd, + check=check, + universal_newlines=True, + cwd=None, + stdout=stdout, + stderr=stderr, + input=input) + + def is_exe(fpath): """Check if the given path is an exexutable file""" return os.path.isfile(fpath) and os.access(fpath, os.X_OK) |
