Use which instead of type to check if a binary exists
For example if mvn is a defined shell function but mvn is not installed the method ensure_exists will return True even mvn is not installed. % type mvn mvn is a shell function % which mvn /usr/bin/which: no mvn in (...) Change-Id: Ic751660c030e687ca6bc53656fd49c5563cfc71f
This commit is contained in:
parent
483122f1fd
commit
23aed8f012
|
@ -723,8 +723,8 @@ def publish_book(publish_path, book):
|
|||
|
||||
def ensure_exists(program):
|
||||
"""Check that program exists, abort if not."""
|
||||
retcode = subprocess.call("type " + program, shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
retcode = subprocess.call(['which', program], stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
if retcode != 0:
|
||||
print("Program '%s' does not exist, please install!" % program)
|
||||
sys.exit(1)
|
||||
|
|
Loading…
Reference in New Issue