Tue, Aug 25, 2015 at 04:53:34PM CEST, jprochaz(a)redhat.com wrote:
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 b42fc86..22d2925 100644
--- a/lnst/Common/Utils.py
+++ b/lnst/Common/Utils.py
@@ -278,3 +278,15 @@ def deprecated(func):
% (func.__name__, self.__class__.__name__))
return func(self, *args, **kwargs)
return log
+
+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
_______________________________________________
LNST-developers mailing list
LNST-developers(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/lnst-developers
ack
Acked-by: Jan Tluka <jtluka(a)redhat.com>