diff --git a/externalProgramPath.py b/externalProgramPath.py index bc0da251771d1a403b7edc5708cd75a0cdc03583..6b169e8dee301d0a7537919b7b667cd676b0788d 100755 --- a/externalProgramPath.py +++ b/externalProgramPath.py @@ -4,7 +4,7 @@ # Define external program paths according to local configuration from prmClasses import * -import os, os.path, distutils.spawn +import os, os.path, shutil #, distutils.spawn class ExtProgs(PRMSet): def __init__(self, verb=False): @@ -71,7 +71,9 @@ class ExtProgs(PRMSet): print("\t 3. If %s not in the Script last version, add it program in the Script..."%key) return False - if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]) : + + #if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]) : # sous windows ne trouve que les .exe => ne marche pas avec .bat & .cmd + if shutil.which(self.pars[key].val): return True else: print("%s is not found in %s ..."%(key, self.pars[key].val)) diff --git a/postProLoop.py b/postProLoop.py index ac7ec14193d1cadfa96c4112e655104d1285ad9d..d66fdfebe1b97d646e83b7b1d22259670d0e9e16 100755 --- a/postProLoop.py +++ b/postProLoop.py @@ -6,7 +6,7 @@ # Define externals program path according to local configuration # from prmClasses import * -import os, os.path, distutils.spawn, time, sys, re, glob +import os, os.path, shutil, time, sys, re, glob #, distutils.spawn import imp #import importlib import externalProgramPath @@ -143,7 +143,16 @@ class PostProLoop(PRMSet): self.pars['LATEXREQUEST'].enable(self.pars['LATEXRUN'].val==True) - def checkValidity(self, key): + def checkValidity(self, key): + #if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]): + if shutil.which(self.pars[key].val): + return True + else: + print "%s is not found (%s)...."%self.pars[key].val + print "\t Check installation and accessibility..." + print "\t Use 'externalProgramPathGui' to define the full program path (recommanded)" + print "\t or add %s in your user path (not recommanded)"%key + return False ''' if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]): return True diff --git a/prmClassesGui.py b/prmClassesGui.py index 3b20bd27509777a2e67127db1ece181439c78ebf..58b4d8d5c7a64b3c8c07226845ae112bc1d785cb 100644 --- a/prmClassesGui.py +++ b/prmClassesGui.py @@ -24,7 +24,7 @@ except: #print "PyQt%d (Qt %s) loaded!" % (foundQt, QT_VERSION_STR) -import distutils.spawn +import shutil #, distutils.spawn from prmClasses import * #======================================================================================== @@ -221,8 +221,9 @@ class ExeFileLine(FileLine): if os.path.isfile(f): # White bg #print "isFile" bgCol = QColor(255, 255, 255) - elif distutils.spawn.find_executable(os.path.splitext(f)[0]): # *.cmd pas reconnu comme exe !!! - #print "find_executable in path" + #elif distutils.spawn.find_executable(os.path.splitext(f)[0]): # *.cmd/*.bat pas reconnu comme exe !!! + elif shutil.which(f): # green bg + print ("found executable in path") bgCol = QColor(0, 255, 0) else: #redBg #print "not found"