diff options
Diffstat (limited to 'src/util.py')
| -rw-r--r-- | src/util.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py index b7d4541..b9f3ce6 100644 --- a/src/util.py +++ b/src/util.py @@ -1,7 +1,28 @@ +import os import sys import src.globalvars + +def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + +def find_cmd(cmd): + fpath, fname = os.path.split(cmd) + + # Search for file + if fpath: + if is_exe(cmd): + return cmd + # Search in PATH + else: + for path in os.environ["PATH"].split(os.pathsep): + exe_file = os.path.join(path, cmd) + if is_exe(exe_file): + return exe_file + + return None + def allocbench_msg(color, *objects, sep=' ', end='\n', file=sys.stdout): if src.globalvars.verbosity < 0: return |
