This method is used for detecting if program is present in $PATH
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Common/Utils.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index c283b99..41958c8 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -263,3 +263,15 @@ def std_deviation(values):
s1 += val
s2 += val**2
return (math.sqrt(len(values)*s2 - s1**2))/len(values)
+
+def is_installed(program):
+ """
+ Returns True if program is detected by which, False otherwise
+ """
+ cmd = "which %s" % program
+ try:
+ subprocess.check_call(cmd, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ return True
+ except subprocess.CalledProcessError:
+ return False
--
2.4.3
Show replies by date