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 | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lnst/Common/Utils.py b/lnst/Common/Utils.py
index c283b99..d198b6f 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -263,3 +263,16 @@ 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
+ process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ output = process.communicate()[0]
+ if process.returncode == 0:
+ return True
+ else:
+ return False
--
2.4.3