commit: ed0de74506f5ce9741fe61c6c1e46701ee7ca3f0
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 19 18:03:44 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Apr 23 18:20:35 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ed0de745
catalyst: Add a function to get full path of executable
Just a simple wrapper around shutil.which().
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/catalyst/support.py b/catalyst/support.py
index 988a81f5..0925af47 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -3,6 +3,7 @@ import glob
import sys
import os
import re
+import shutil
import time
from subprocess import Popen
@@ -17,6 +18,11 @@ class CatalystError(Exception):
if message:
log.error('CatalystError: %s', message, exc_info=print_traceback)
+def command(name):
+ c = shutil.which(name)
+ if not c:
+ raise CatalystError(f'"{name}" not found or is not executable')
+ return c
def cmd(mycmd, env=None, debug=False, fail_func=None):
"""Run the external |mycmd|.