forked from qt-creator/qt-creator
Squish: Use existing tools for finding executables
Change-Id: Ic3e7f5db6d12e37f908df3290893768a5be4fa56 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -138,37 +138,16 @@ def textUnderCursor(window, fromPos, toPos):
|
|||||||
return returnValue
|
return returnValue
|
||||||
|
|
||||||
def which(program):
|
def which(program):
|
||||||
def is_exe(fpath):
|
# Don't use spawn.find_executable because it can't find .bat or
|
||||||
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
|
# .cmd files and doesn't check whether a file is executable (!)
|
||||||
|
|
||||||
def callableFile(path):
|
|
||||||
if is_exe(path):
|
|
||||||
return path
|
|
||||||
if platform.system() in ('Windows', 'Microsoft'):
|
if platform.system() in ('Windows', 'Microsoft'):
|
||||||
for suffix in suffixes.split(os.pathsep):
|
command = "where"
|
||||||
if is_exe(path + suffix):
|
else:
|
||||||
return path + suffix
|
command = "which"
|
||||||
return None
|
foundPath = getOutputFromCmdline(command + " " + program)
|
||||||
|
if foundPath:
|
||||||
if platform.system() in ('Windows', 'Microsoft'):
|
return foundPath.splitlines()[0]
|
||||||
suffixes = os.getenv("PATHEXT")
|
|
||||||
if not suffixes:
|
|
||||||
test.fatal("Can't read environment variable PATHEXT. Please check your installation.")
|
|
||||||
suffixes = ""
|
|
||||||
|
|
||||||
fpath, fname = os.path.split(program)
|
|
||||||
if fpath:
|
|
||||||
return callableFile(program)
|
|
||||||
else:
|
else:
|
||||||
if platform.system() in ('Windows', 'Microsoft'):
|
|
||||||
cf = callableFile(os.getcwd() + os.sep + program)
|
|
||||||
if cf:
|
|
||||||
return cf
|
|
||||||
for path in os.environ["PATH"].split(os.pathsep):
|
|
||||||
exe_file = os.path.join(path, program)
|
|
||||||
cf = callableFile(exe_file)
|
|
||||||
if cf:
|
|
||||||
return cf
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# this function removes the user files of given pro file(s)
|
# this function removes the user files of given pro file(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user