def FindPythonExe(exeAlias, possibleRealNames, searchPaths): """Find an exe. Returns the full path to the .exe, and a boolean indicating if the current registered entry is OK. We don't trust the already registered version even if it exists - it may be wrong (ie, for a different Python version) """ import win32api, regutil, string, os, sys if possibleRealNames is None: possibleRealNames = exeAlias # Look first in Python's home. found = os.path.join(sys.prefix, possibleRealNames) if not FileExists(found): # for developers found = os.path.join(sys.prefix, "PCBuild", possibleRealNames) if not FileExists(found): found = LocateFileName(possibleRealNames, searchPaths) registered_ok = 0 try: registered = win32api.RegQueryValue( regutil.GetRootKey(), regutil.GetAppPathsKey() + "\\" + exeAlias) registered_ok = found == registered except win32api.error: pass return found, registered_ok
def CheckRegisteredExe(exename): try: os.stat( win32api.RegQueryValue(regutil.GetRootKey(), regutil.GetAppPathsKey() + "\\" + exename)) # except SystemError: except (os.error, win32api.error): print("Registration of %s - Not registered correctly" % exename)
def FindPythonExe(exeAlias, possibleRealNames, searchPaths): """Find an exe. First place looked is the registry for an existing entry. Then the searchPaths are searched. Returns the full path to the .exe, and a boolean indicating if the current registered entry is OK. """ import _winreg, regutil, string if possibleRealNames is None: possibleRealNames = exeAlias try: fname = _winreg.QueryValue(regutil.GetRootKey(), regutil.GetAppPathsKey() + "\\" + exeAlias) if FileExists(fname): return fname, 1 # Registered entry OK except EnvironmentError: pass return LocateFileName(possibleRealNames, searchPaths), 0