'PySide2/plugins/styles', ) for name in dirs: pth = os.path.join('dist', eng, name) if os.path.exists(pth): shutil.rmtree(pth) except: import traceback traceback.print_exc() exit(1) # Now locate the InnoSetup compiler try: innoCmd = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, "InnoSetupScriptFile\shell\Compile\command") except WindowsError: print() print("ERROR: Unable to locate your Inno Setup installation in the registry!") print("Have you installed Inno Setup? http://www.jrsoftware.org/isdl.php") exit(1) innoCmd = innoCmd.replace("\"%1\"", "setup.iss") try: subprocess.check_call(innoCmd, shell=True) except subprocess.CalledProcessError: print() print("ERROR running Inno Setup") print("Failed to build installer...") exit(1)
def OnMenu(self, EVT): self.destro = wx.GetKeyState(wx.WXK_CONTROL) PACKAGE = 2 MODULO = 3 TITOLO = 4 ABILITAZIONE = 5 TCPART = 6 rec = "" ID = EVT.GetId() if ID == MENU_EDIT_DELETE_PAGE: # e' stato premuto sposta in finestra dai tab idtab = self.notebook_1.GetSelection() idObj = self.notepageObj[idtab] idmenu = self.notepageID[idtab] self.sizer_6.Detach(idObj) #chiamare evento close della finestra del self.notepageObj[idtab] del self.notepageID[idtab] self.chiuditab = True self.notebook_1.DeletePage(idtab) if len(self.notepageObj) == 0: self.notebook_1.Show(False) self.sizer_6.Add(self.win_logo_MDI, 1, wx.EXPAND, 0) self.sizer_6.Layout() self.win_logo_MDI.Show(True) self.winMDI.Layout() self.tab = False somaro = MyFrame(self.winMDI, -1, self.vcMENU[idmenu][TITOLO]) idObj.Reparent(somaro) somaro.child = idObj idObj.GetSizer().Fit(idObj) somaro.SetClientSize(somaro.child.GetSize()) somaro.Centre(wx.BOTH) somaro.Refresh() somaro.Show(True) somaro.child.SetFocus() self.frampageID.append(idmenu) self.frampageObj.append(idObj) self.frampageFra.append(somaro) elif ID == LISTA_MODULI_APERTI: if len(self.notepageID) > 0 or len(self.frampageID) > 0: NavDialog = AllModulNavigation(self) NavDialog.Centre(wx.BOTH) IDNavDialog = NavDialog.ShowModal() NavDialog.Destroy() if IDNavDialog >= 0 and IDNavDialog != wx.ID_CANCEL: self.ProcessCommand(IDNavDialog) #ID_CANCEL=5101 elif ID <= 10000: self.IDMENU = ID vcMENU = self.vcMENU if (str(vcMENU[ID][TCPART]) == "CLOSE"): self.Close(None) #self.Selaz() elif (str(vcMENU[ID][TCPART]) == "ABOUT"): self.About() elif (str(vcMENU[ID][TCPART]) == "EXEC"): wx.Execute(vcMENU[ID][MODULO]) elif (vcMENU[ID][6] == "PDF"): nomeDoc = cfg.path_work + "manuale-utente.pdf" if sys.platform == 'win32': nomeDoc = string.replace(nomeDoc, "/", "\\") import _winreg acrobat = _winreg.QueryValue( _winreg.HKEY_CLASSES_ROOT, 'AcroExch.Document\shell\open\command')[1:-6] cmd = '"%s" %s' pid = wx.Execute(cmd % (acrobat, nomeDoc)) elif wx.Platform == '__WXMAC__': #os.popen("open " + nomeDoc) pid = os.system("open " + nomeDoc) #os.startfile(nomeDoc) #sembra fuznionare solo su window else: pid = wx.Execute("evince " + nomeDoc) elif (vcMENU[ID][TCPART] == "URL"): url = vcMENU[ID][MODULO] #wx.LaunchDefaultBrowser(url) try: import webbrowser except ImportError: wx.MessageBox(_('Attenzione:') + ' %s' % url) else: webbrowser.open(url) else: self.CMD(ID, rec, vcMENU[ID][TCPART])
def package_finish(self): # a standard map of strings for replacing in the templates substitution_strings = { 'version': '.'.join(self.args['version']), 'version_short': '.'.join(self.args['version'][:-1]), 'version_dashes': '-'.join(self.args['version']), 'final_exe': self.final_exe(), 'grid': self.args['grid'], 'grid_caps': self.args['grid'].upper(), # escape quotes becase NSIS doesn't handle them well 'flags': self.flags_list().replace('"', '$\\"'), 'channel': self.channel(), 'channel_oneword': self.channel_oneword(), 'channel_unique': self.channel_unique(), } version_vars = """ !define INSTEXE "%(final_exe)s" !define VERSION "%(version_short)s" !define VERSION_LONG "%(version)s" !define VERSION_DASHES "%(version_dashes)s" """ % substitution_strings installer_file = "Singularity_%(version_short)s_Setup.exe" grid_vars_template = """ OutFile "%(installer_file)s" !define VIEWERNAME "Singularity Viewer" !define INSTFLAGS "%(flags)s" !define INSTNAME "SingularityViewer" !define SHORTCUT "Singularity Viewer" !define URLNAME "secondlife" !define INSTALL_ICON "install_icon_singularity.ico" !define UNINSTALL_ICON "install_icon_singularity.ico" Caption "Singularity Viewer ${VERSION}" """ if 'installer_name' in self.args: installer_file = self.args['installer_name'] else: installer_file = installer_file % substitution_strings substitution_strings['installer_file'] = installer_file tempfile = "secondlife_setup_tmp.nsi" # the following replaces strings in the nsi template # it also does python-style % substitution self.replace_in( "installers/windows/installer_template.nsi", tempfile, { "%%VERSION%%": version_vars, "%%SOURCE%%": self.get_src_prefix(), "%%GRID_VARS%%": grid_vars_template % substitution_strings, "%%INSTALL_FILES%%": self.nsi_file_commands(True), "%%DELETE_FILES%%": self.nsi_file_commands(False) }) # We use the Unicode version of NSIS, available from # http://www.scratchpaper.com/ try: import _winreg as reg NSIS_path = reg.QueryValue( reg.HKEY_LOCAL_MACHINE, r"SOFTWARE\NSIS\Unicode") + '\\makensis.exe' self.run_command('"' + proper_windows_path(NSIS_path) + '" ' + self.dst_path_of(tempfile)) except: try: NSIS_path = os.environ[ 'ProgramFiles'] + '\\NSIS\\Unicode\\makensis.exe' self.run_command('"' + proper_windows_path(NSIS_path) + '" ' + self.dst_path_of(tempfile)) except: NSIS_path = os.environ[ 'ProgramFiles(X86)'] + '\\NSIS\\Unicode\\makensis.exe' self.run_command('"' + proper_windows_path(NSIS_path) + '" ' + self.dst_path_of(tempfile)) # self.remove(self.dst_path_of(tempfile)) # If we're on a build machine, sign the code using our Authenticode certificate. JC sign_py = os.path.expandvars("{SIGN_PY}") if sign_py == "" or sign_py == "{SIGN_PY}": sign_py = 'C:\\buildscripts\\code-signing\\sign.py' if os.path.exists(sign_py): self.run_command('python ' + sign_py + ' ' + self.dst_path_of(installer_file)) else: print "Skipping code signing,", sign_py, "does not exist" self.created_path(self.dst_path_of(installer_file)) self.package_file = installer_file
if os.name == 'nt': if not ctypes.windll.shell32.IsUserAnAdmin(): print('\nThis script requires to be ran with admin privileges\n') sys.exit() if sys.version[0] == '2': input = raw_input import _winreg as wreg else: import winreg as wreg #create key key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "Software\\TestCompany\\TestProject") # Create new subkey wreg.SetValue(key, 'NewSubkey', wreg.REG_SZ, 'testsubkey') print(wreg.QueryValue(key, 'NewSubKey')) # prints 'testsubkey' # Create new value wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_SZ, 'testvalue') print(wreg.QueryValueEx(key,'ValueName')) # prints (u'testvalue', 1) key.Close() #read value key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "Software\\TestCompany\\TestProject",0,wreg.KEY_ALL_ACCESS) wreg.SetValue(key, 'NewSubkey', wreg.REG_SZ, 'subkey_changed') print(wreg.QueryValue(key, 'NewSubkey')) # prints 'subkey_changed' wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_SZ, 'value_changed') print(wreg.QueryValueEx(key, 'ValueName'))
def get_subkey(self, name): " Get subkey (Default) value out of registry " return wreg.QueryValue(self.key, name)
def get(self, name): """ Get value by name """ return reg.QueryValue(self.key, name)
def search_ipy_reg(regkeys=None, executable=constants.EXECUTABLE, detailed=False): """Search for IronPython regisitry keys. This function searches for IronPython keys in the Windows registry, and returns a dictionary showing the versions of IronPython and their locations (the paths to the IronPython directories). :param list regkeys: (optional) The IronPython registry keys that should be looked for. :param str executable: (optional) The name of the IronPython executable. :param bool detailed: (optional) If this parameter is true, the key of the dictionary will be an instance of :class:`ironpycompiler.datatypes.HashableVersion` instead of string, in order to provide detailed information of versions. :return: The versions of IronPython and their locations :rtype: dict :raises ironpycompiler.exceptions.IronPythonDetectionError: if IronPython keys cannot be found .. versionadded:: 0.9.0 .. versionchanged:: 0.10.1 Solved the problem that the default value for the argument ``regkeys`` was mutable. .. versionchanged:: 1.0.0 Validates the found executables using :func:`validate_pythonexe`. The parameters ``detailed`` and ``executable`` were added. """ if regkeys is None: regkeys = constants.REGKEYS try: import _winreg except ImportError: raise exceptions.IronPythonDetectionError( msg="Cannot import a module for accessing the Windows registry.") foundipys = dict() ipybasekey = None # IronPythonキーを読み込む for key in regkeys: try: ipybasekey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key) except WindowsError: continue else: break if ipybasekey is None: ipybasekey.Close() raise exceptions.IronPythonDetectionError( msg="Could not find any IronPython registry key.") else: itr = itertools.count() foundvers = [] for idx in itr: try: foundvers.append(_winreg.EnumKey(ipybasekey, idx)) except WindowsError: # 対応するサブキーがなくなったら break foundipys = dict() for ver in foundvers: ipypathkey = _winreg.OpenKey(ipybasekey, ver + "\\InstallPath") ipy_dir = os.path.dirname(_winreg.QueryValue(ipypathkey, None)) ipy_exe = os.path.abspath(os.path.join(ipy_dir, executable)) try: ipy_ver = validate_pythonexe(ipy_exe) except exceptions.IronPythonValidationError: continue else: if detailed: foundipys[ipy_ver] = ipy_dir else: foundipys[ipy_ver.major_minor()] = ipy_dir finally: ipypathkey.Close() ipybasekey.Close() if len(foundipys) == 0: raise exceptions.IronPythonDetectionError( msg="Could not find any IronPython executable.") return foundipys
#!/usr/bin/python import _winreg as wreg for base, path in zip((wreg.HKEY_CLASSES_ROOT, wreg.HKEY_CLASSES_ROOT), ( "Applications\\python.exe\\shell\\open", "py_auto_file\\shell\\open", )): key = wreg.OpenKey(base, path, 0, wreg.KEY_ALL_ACCESS) old_value = wreg.QueryValue(key, 'command') if old_value.endswith('"%1"'): print('Fixing registry: {0}\\{1}'.format(base, path)) new_value = old_value + ' %*' wreg.SetValue(key, 'command', wreg.REG_SZ, new_value)
def find_python(): with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, python_regpath) as key: try: return _winreg.QueryValue(key, "InstallPath") except WindowsError: return ""
def getitemdefaultvalue(regpath): key = regpath.split('\\')[len(regpath.split('\\')) - 1] root = regpath.split('\\')[0].upper() path = '\\'.join(regpath.split('\\')[1:len(regpath.split('\\')) - 1]) keyHandle = _winreg.OpenKey(regDict[root], path) return _winreg.QueryValue(keyHandle, key)
def get(self): with winreg.OpenKey(self.software_key, self.service_name_key) as srv_key: value = winreg.QueryValue(srv_key, self.config_name_key) return value
def GetCommand(pFileType, pCommandName): lKey = pFileType + '\\Shell\\' + pCommandName + '\\Command' print lKey lCommand = reg.QueryValue(reg.HKEY_CLASSES_ROOT, lKey) print lCommand return lCommand
associated with the given value, or, if none is given, whether the extension is associated with anything at all. """ try: handle = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, extension, 0, _winreg.KEY_QUERY_VALUE) except WindowsError, e: if e.errno == 2: # Key does not exist return False else: raise try: reg_value = _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, extension) if value: is_associated = reg_value.lower() == value.lower() else: is_associated = len(reg_value) > 0 except ValueError: is_associated = False return is_associated def get_main_window_dimensions(self): """Gets x, y, width, height from config. Returns Rect. """ max_width = gtk.gdk.screen_width() max_height = gtk.gdk.screen_height()
oledll.ole32.StringFromCLSID(byref(b), byref(p)) print("CLSID GUID: " + str(p.value)) p = c_wchar_p() b = create_string_buffer(a) try: oledll.ole32.ProgIDFromCLSID(byref(b), byref(p)) progname = str(p.value) print(progname) except: progname = "unknown" print('unknown') iid = struct.pack('<IHHBBBBBBBB', Dword(iid_addr), Word(iid_addr + 4), Word(iid_addr + 6), Byte(iid_addr + 8), Byte(iid_addr + 9), Byte(iid_addr + 10), Byte(iid_addr + 11), Byte(iid_addr + 12), Byte(iid_addr + 13), Byte(iid_addr + 14), Byte(iid_addr + 15)) p = c_wchar_p() b = create_string_buffer(iid) oledll.ole32.StringFromCLSID(byref(b), byref(p)) iid = str(p.value) print("IID GUID: " + iid) if progname != "unknown": service = _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, "Interface\\" + iid) print(service) MakeComm(called_addr, service)
def get_path(self, reg): return _winreg.QueryValue(reg, 'command').rsplit(' ', 1)[0].strip('"')
def get_com_info(*additional_keys): """Reads the registry for the COM_ libraries that are available. This function is only supported on Windows. .. versionadded:: 0.5 .. _COM: https://en.wikipedia.org/wiki/Component_Object_Model .. _Class ID: https://docs.microsoft.com/en-us/windows/desktop/com/clsid-key-hklm Parameters ---------- *additional_keys : :class:`str`, optional The Program ID (ProgID) key is returned automatically. You can include additional keys (e.g., Version, InprocHandler32, ToolboxBitmap32, VersionIndependentProgID, ...) if you also want this additional information to be returned for each `Class ID`_. Returns ------- :class:`dict` The keys are the Class ID's and each value is a :class:`dict` of the information that was requested. Examples -------- >>> from msl.loadlib import utils >>> info = utils.get_com_info() >>> info = utils.get_com_info('Version', 'ToolboxBitmap32') """ if winreg is None: return {} results = {} for item in ['CLSID', r'Wow6432Node\CLSID']: try: key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, item) except OSError: continue else: logger.debug(r'Parsing HKEY_CLASSES_ROOT\{}\...'.format(item)) index = -1 while True: index += 1 try: clsid = winreg.EnumKey(key, index) except OSError: break sub_key = winreg.OpenKey(key, clsid) # ProgID is mandatory, if this fails then ignore # this CLSID and go to the next index in the registry try: progid = winreg.QueryValue(sub_key, 'ProgID') except OSError: pass else: results[clsid] = {} results[clsid]['ProgID'] = progid for name in additional_keys: try: results[clsid][name] = winreg.QueryValue(sub_key, name) except OSError: results[clsid][name] = None finally: winreg.CloseKey(sub_key) winreg.CloseKey(key) return results
print('\nCreated GSAS-II batch file RunGSASII.bat in ' + gsaspath) new = False oldBat = '' try: # patch for FileNotFoundError not in Python 2.7 FileNotFoundError except NameError: FileNotFoundError = Exception # this code does not appear to work properly when paths have spaces try: oldgpx = winreg.OpenKey( winreg.HKEY_CURRENT_USER, r'Software\CLASSES\GSAS-II.project') # throws FileNotFoundError oldopen = winreg.OpenKey(oldgpx, r'shell\open\command') # get previous value & strip %1 off end oldBat = winreg.QueryValue(oldopen, None).strip() pos = oldBat.rfind(' ') if pos > 1: oldBat = oldBat[:pos] os.stat(oldBat) #check if it is still around except FileNotFoundError: if oldBat: print('old GPX assignment', oldBat, 'not found; registry entry will be made for new one') new = True if not new: try: if oldBat != G2bat: if app is None: app = wx.App() app.MainLoop()
def getPyCharmDebugEggPath(self, enableAutoDetect=False): # If path is defined in settings then use that settings = qt.QSettings() if settings.contains('Developer/PyCharmDebugEggPath'): pyCharmDebugEggPath = settings.value( 'Developer/PyCharmDebugEggPath') if self.isValidPyCharmDebugEggPath(pyCharmDebugEggPath): # found a good value in the settings return pyCharmDebugEggPath if not enableAutoDetect: return '' # Auto-detect import platform if platform.system() == 'Windows': try: # Python2 import _winreg as winreg except ImportError: # Python3 import winreg value = None pycharmExeKeys = [ r"Applications\pycharm.exe\shell\open\command", r"Applications\pycharm64.exe\shell\open\command" ] for pycharmExeKey in pycharmExeKeys: try: aReg = winreg.ConnectRegistry(None, winreg.HKEY_CLASSES_ROOT) aKey = winreg.OpenKey(aReg, pycharmExeKey) value = winreg.QueryValue(aKey, None) if value: # found a non-empty value break except: # not found pass if not value: # PyCharm not found in registry return '' logging.debug("PyCharm was found in registry: " + value) # Get PyCharm path by removing bin\pycharm... and anything beyond that # from value variable, which initially contains something like: # 'C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\bin\pycharm.exe "%1"' pyCharmPath = value[:value.find(r"\bin\pycharm.exe")] pyCharmPath = value[:value.find(r"\bin\pycharm64.exe")] # remove leading " character if present if pyCharmPath[0] == "\"": pyCharmPath = pyCharmPath[1:] pyCharmDebugEggPath = pyCharmPath + r"\debug-eggs\pycharm-debug.egg" if self.isValidPyCharmDebugEggPath(pyCharmDebugEggPath): # found a good value in registry return pyCharmDebugEggPath pyCharmDebugEggPath = pyCharmPath + r"\debug-eggs\pydevd-pycharm.egg" if self.isValidPyCharmDebugEggPath(pyCharmDebugEggPath): # found a good value in registry return pyCharmDebugEggPath # Not found return ''
def RegisterPythonServer(filename, progids=None, verbose=0): if progids: if isinstance(progids, basestring): progids = [progids] # we know the CLSIDs we need, but we might not be an admin user # and otherwise unable to register them. So as long as the progids # exist and the DLL points at our version, assume it already is. why_not = None for progid in progids: try: clsid = pythoncom.MakeIID(progid) except pythoncom.com_error: # no progid - not registered. break # have a CLSID - open it. try: HKCR = _winreg.HKEY_CLASSES_ROOT hk = _winreg.OpenKey(HKCR, "CLSID\\%s" % clsid) dll = _winreg.QueryValue(hk, "InprocServer32") except WindowsError: # no CLSID or InProcServer32 - not good! break ok_files = [ os.path.basename(pythoncom.__file__), 'pythoncomloader%d%d.dll' % (sys.version_info[0], sys.version_info[1]) ] if os.path.basename(dll) not in ok_files: why_not = "%r is registered against a different Python version (%s)" % ( progid, dll) break else: #print "Skipping registration of '%s' - already registered" % filename return # needs registration - see if its likely! try: from win32com.shell.shell import IsUserAnAdmin except ImportError: print "Can't import win32com.shell - no idea if you are an admin or not?" is_admin = False else: try: is_admin = IsUserAnAdmin() except pythoncom.com_error: # old, less-secure OS - assume *is* admin. is_admin = True if not is_admin: msg = "%r isn't registered, but I'm not an administrator who can register it." % progids[ 0] if why_not: msg += "\n(registration check failed as %s)" % why_not # throw a normal "class not registered" exception - we don't report # them the same way as "real" errors. raise pythoncom.com_error(winerror.CO_E_CLASSSTRING, msg, None, -1) # so theoretically we are able to register it. cmd = '%s "%s" --unattended > nul 2>&1' % (win32api.GetModuleFileName(0), filename) if verbose: print "Registering engine", filename # print cmd rc = os.system(cmd) if rc: print "Registration command was:" print cmd raise RuntimeError("Registration of engine '%s' failed" % filename)
import sublime_plugin import sublime import os from subprocess import Popen try: import _winreg as winreg except: import winreg try: WINMERGE = winreg.QueryValue( winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinMergeU.exe') except: if os.path.isfile( os.path.join(os.environ['ProgramFiles(x86)'], "WinMerge", "WinMergeU.exe")): WINMERGE = os.path.join(os.environ['ProgramFiles(x86)'], "WinMerge", "WinMergeU.exe") elif os.path.isfile( os.path.join(os.environ['ProgramFiles'], "WinMerge", "WinMergeU.exe")): WINMERGE = os.path.join(os.environ['ProgramFiles'], "WinMerge", "WinMergeU.exe") elif os.path.isfile( os.path.join( os.path.dirname(os.path.dirname(sublime.executable_path())), "WinMergePortable", "WinMergePortable.exe")): WINMERGE = os.path.join( os.path.dirname(os.path.dirname(sublime.executable_path())), "WinMergePortable", "WinMergePortable.exe")
def start_services(self): start_service = True # Is vbox installed ? vboxdrv_state = self.get_service_state("VBoxDrv") if vboxdrv_state == "RUNNING": # try to unload VboxDrv self.stop_service("VBoxDrv") # is service is really stopped ? vboxdrv_state = self.get_service_state("VBoxDrv") if vboxdrv_state != "STOPPED" or not os.environ.get( "VBOX_INSTALL_PATH"): return 2 self.vbox_install = os.environ.get("VBOX_INSTALL_PATH") elif vboxdrv_state == "STOP_PENDING": return 2 if conf.CREATESRVS: create_service = True portable_vboxdrv_state = self.get_service_state("PortableVBoxDrv") if portable_vboxdrv_state == "STOPPED": logging.debug("Removing PortableVBoxDrv") self.call(["sc", "delete", "PortableVBoxDrv"], shell=True) elif portable_vboxdrv_state == "RUNNING": logging.debug("Service PortableVBoxDrv is running") create_service = False start_service = False if create_service: logging.debug("Creating services :") if self.create_service( "PortableVBoxDrv", path.join(conf.VBOXDRIVERS, "VBoxDrv.sys")) != 0: # We dont have root permissons return 1 if self.puel: self.create_service( "PortableVBoxUSBMon", path.join(conf.BIN, "drivers", "USB", "filter", "VBoxUSBMon.sys")) try: key = _winreg.OpenKey( _winreg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\VBoxUSB") if _winreg.QueryValue(key, "DisplayName") != "VirtualBox USB": self.create_service( "VBoxUSB", path.join(conf.BIN, "drivers", "USB", "device", "VBoxUSB.sys")) except: logging.debug( "The key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\VBoxUSB does not exist" ) if conf.STARTSRVS and start_service: logging.debug("Starting services :") start_portable_vboxdrv = self.start_service("PortableVBoxDRV") if start_portable_vboxdrv in [1060, 5]: logging.debug("Got error: " + str(code) + " " + output) return 1 elif start_portable_vboxdrv == 183: logging.debug( "VirtualBox seems to be installed but not catched (sc start service returns 183)" ) return 2 if self.puel: self.start_service("PortableVBoxUSBMon") logging.debug("Re-registering server:") if not self.register_vbox_com(conf.BIN): return 1 return 0
# it also does python-style % substitution self.replace_in("installers/windows/installer_template.nsi", tempfile, { "%%VERSION%%":version_vars, "%%SOURCE%%":self.get_src_prefix(), "%%GRID_VARS%%":grid_vars_template % substitution_strings, "%%INSTALL_FILES%%":self.nsi_file_commands(True), "%%DELETE_FILES%%":self.nsi_file_commands(False), "%%INSTALLDIR%%":"%s\\%s" % ('$PROGRAMFILES64' if self.is_win64() else '$PROGRAMFILES', self.channel_oneword()), "%%WIN64_BIN_BUILD%%":"!define WIN64_BIN_BUILD 1" if self.is_win64() else "", }) # We use the Unicode version of NSIS, available from # http://www.scratchpaper.com/ try: import _winreg as reg NSIS_path = reg.QueryValue(reg.HKEY_LOCAL_MACHINE, r"SOFTWARE\NSIS\Unicode") + '\\makensis.exe' self.run_command([proper_windows_path(NSIS_path), self.dst_path_of(tempfile)]) except: try: NSIS_path = os.environ['ProgramFiles'] + '\\NSIS\\Unicode\\makensis.exe' self.run_command([proper_windows_path(NSIS_path), self.dst_path_of(tempfile)]) except: NSIS_path = os.environ['ProgramFiles(X86)'] + '\\NSIS\\Unicode\\makensis.exe' self.run_command([proper_windows_path(NSIS_path),self.dst_path_of(tempfile)]) # self.remove(self.dst_path_of(tempfile)) # Sign the installer if 'VIEWER_SIGNING_PASSWORD' in os.environ: try: self.sign(self.args['configuration'] + "\\" + substitution_strings['installer_file']) except Exception, e:
def value(self, segments): print '*** RegisteryKey.value.self:', self._key, segments print winreg.QueryValue(self._key, self._path_from(segments)) return _winreg.QueryValue(self._key, self._path_from(segments))
def read_global_prefs(name): try: return _winreg.QueryValue(simics_key, name) except: return None
] if x64: handle = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Classes\\Interface', 0, _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY) else: handle = _winreg.OpenKeyEx(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Classes\\Interface') res = {} for i in range(_winreg.QueryInfoKey(handle)[0]): try: name = _winreg.EnumKey(handle, i) value = _winreg.QueryValue(handle, name) except WindowsError: continue for item in iids: if value.endswith(item): print(value, name) res['IID_' + item] = GUID(name.upper()) break _winreg.CloseKey(handle) mod = sys.modules[__name__] if __name__ == '__main__': for key, value in mod.__dict__.items():
def __get_value(self): 'Private class method.' return _winreg.QueryValue(self.__self, '')
def find_python_from_registry(location, reg=None): if platform.system() != 'Windows' or winreg is None: return None if reg is None: path = find_python_from_registry(location, reg=winreg.HKEY_CURRENT_USER) if path is None: path = find_python_from_registry(location, reg=winreg.HKEY_LOCAL_MACHINE) return path val = None sub_key = 'InstallPath' compiled = re.compile(r'^\d+\.\d+$') try: with winreg.OpenKey(reg, location) as handle: versions = [] try: for index in range(1024): version = winreg.EnumKey(handle, index) try: if compiled.search(version): versions.append(version) except re.error: pass except EnvironmentError: pass versions.sort(reverse=True) for version in versions: try: path = winreg.QueryValue(handle, version + '\\' + sub_key) if path is not None: path = find_python_in_folder(path) if path is not None: log( DEBUG, 'Found python from {reg}\\{key}\\{version}\\{sub_key}.' .format( reg=reg, key=location, version=version, sub_key=sub_key, )) return path except WindowsError: log( DEBUG, 'Could not read registry value "{reg}\\{key}\\{version}\\{sub_key}".' .format( reg=reg, key=location, version=version, sub_key=sub_key, )) except WindowsError: log( DEBUG, 'Could not read registry value "{reg}\\{key}".'.format( reg=reg, key=location, )) except: log( ERROR, 'Could not read registry value "{reg}\\{key}":\n{exc}'.format( reg=reg, key=location, exc=traceback.format_exc(), )) return val
def get_path(self, reg): return _winreg.QueryValue(reg, 'DefaultIcon').rsplit(',', 1)[0]
def checkForBuildTools(self): global MAKENSIS_exe, SVN_exe log.debug('========== checkForBuildTools()') if sys.platform == 'win32': import _winreg as winreg # Find NSIS on system try: with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\NSIS') as key: nsispath = winreg.QueryValue(key, '') makensisexe = path.join(nsispath, 'makensis.exe') if path.isfile(makensisexe): MAKENSIS_exe = makensisexe except WindowsError, e: log.warning('NSIS not found, in registory') log.warning('..Testing if makensis is on the path') MAKENSIS_exe = 'makensis' #cmd = os.path.join(nsis_dir, MAKENSIS_exe) cmd = '%s /VERSION' % MAKENSIS_exe proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() output = string.strip(out) log.info(output) if err: log.error(err) log.error('....makensis.exe not found on path') sys.exit(0) #else: # log.info("makensis version %s" % output) # Find msgfmt on system cmd = os.path.join(msg_dir, 'msgfmt.exe') proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() output = string.strip(out) log.info(output) if not err.startswith(cmd): #log.error(err) log.error('msgfmt.exe not found on path') log.error( ' try the -m DIR , --msgdir=DIR option to specify the directory or put it on the path' ) sys.exit(0) # Find SVN on system - optional, if building from tarball if not bTarball: try: with winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\svn.exe' ) as key: svnpath = winreg.QueryValue(key, '') if path.isfile(svnpath): SVN_exe = svnpath except WindowsError, e: log.warning('SVN not found, in registory') log.warning('... Hoping svn is on the path') SVN_exe = 'svn'
def checkForBuildTools(self): global MAKENSIS_exe, SVN_exe log.debug('========== checkForBuildTools()') if sys.platform == 'win32': import _winreg as winreg # Find NSIS on system try: with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\NSIS') as key: nsispath = winreg.QueryValue(key, '') makensisexe = path.join(nsispath, 'makensis.exe') if path.isfile(makensisexe): MAKENSIS_exe = makensisexe except WindowsError as e: log.warning('NSIS not found, in registory') log.warning('..Testing if makensis is on the path') MAKENSIS_exe = 'makensis' #cmd = os.path.join(nsis_dir, MAKENSIS_exe) cmd = '%s /VERSION' % MAKENSIS_exe proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() output = string.strip(out) log.info(output) if err: log.error(err) log.error('....makensis.exe not found on path') sys.exit(0) #else: # log.info("makensis version %s" % output) # Find msgfmt on system cmd = os.path.join(msg_dir, 'msgfmt.exe') proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = proc.communicate() output = string.strip(out) log.info(output) if not err.startswith(cmd): #log.error(err) log.error('msgfmt.exe not found on path') log.error( ' try the -m DIR , --msgdir=DIR option to specify the directory or put it on the path' ) sys.exit(0) # Find SVN on system - optional, if building from tarball if not bTarball: try: with winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\svn.exe' ) as key: svnpath = winreg.QueryValue(key, '') if path.isfile(svnpath): SVN_exe = svnpath except WindowsError as e: log.warning('SVN not found, in registory') log.warning('... Hoping svn is on the path') SVN_exe = 'svn' elif sys.platform == 'linux2': #ASSUMPTION: these tools are on the path #TODO: check for svn on Linux log.info('TODO: Check for svn') SVN_exe = 'svn' #TODO: check for nsis on Linux log.info('TODO: Check for nsis') MAKENSIS_exe = 'makensis' # Check if we are running a compatible vesion of NSIS vers = self.getNSISVersionNumber() if vers < MIN_NSIS_VERSION: log.error( "Require NSIS version %d.%d or later ..... found NSIS version %d.%d" % (MIN_NSIS_VERSION[0], MIN_NSIS_VERSION[1], vers[0], vers[1])) log.info( "Disabling NSIS compilation ... Please upgrade your NSIS version" ) self.bBuildInstaller = False else: self.bBuildInstaller = True log.info("NSIS version %d.%d" % vers)