aboutsummaryrefslogtreecommitdiff
path: root/src/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.py')
-rw-r--r--src/util.py26
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)