/
executables.py
37 lines (31 loc) · 1.32 KB
/
executables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# coding=utf-8
"""
Helper for verifying that 3rd party applications are available for use.
"""
__docformat__ = 'restructuredtext en'
from herringlib.local_shell import LocalShell
from herringlib.simple_logger import warning
HELP = {
'pynsource': "pyNsource generates class diagrams. "
"Please install from http://www.andypatterns.com/index.php/products/pynsource/",
'pyreverse': 'pyreverse generates package and class UML diagrams and is part of pylint. Please install pylint.',
'rstlint': 'rstlint checks the RST in the given file. '
'Please install from http://svn.python.org/projects/python/trunk/Doc/tools/',
}
def executables_available(executable_list):
"""
Check if the given applications are on the path using the 'which' command.
:param executable_list: list of application names
:type executable_list: list of str instances
:return: asserted if all are available
:rtype: bool
"""
with LocalShell() as local:
for executable in executable_list:
if not local.system("which {name}".format(name=executable), verbose=False).strip():
if executable in HELP:
warning(HELP[executable])
else:
warning("Please install: %s" % executable)
return False
return True