Make no_command work only when apt available

This commit is contained in:
nvbn
2015-04-17 16:36:38 +02:00
parent 2eb777a5bb
commit 1503dcf294
3 changed files with 42 additions and 9 deletions
+19
View File
@@ -0,0 +1,19 @@
import os
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None