def get_platform(): global os rv = OSInfo() rv.platform = sys.platform if sys.platform.startswith("linux"): import os # making this global breaks on IronPython osname, _, kernel, _, arch = os.uname() rv.arch = arch rv.osname = osname rv.osversion = kernel rv.distribution, rv.release = _get_linux_dist() elif sys.platform.startswith("darwin"): import os # making this global breaks on IronPython osname, _, kernel, _, arch = os.uname() rv.arch = arch rv.osname = osname rv.osversion = kernel rv.distribution, rv.release = _get_darwin_dist() elif sys.platform in ("win32", "cli"): import os rv.arch = os.environ["PROCESSOR_ARCHITECTURE"] rv.osname = os.environ["OS"] rv.distribution = "Microsoft" if sys.platform == "win32": import win32api major, minor, build, api, extra = win32api.GetVersionEx() rv.osversion = "%d.%d.%d-%s" % (major, minor, build, extra) rv.release = "Unknown" elif sys.platform == "cli": rv.osversion = "Unknown" rv.release = "Unknown" return rv
def get_machine_and_user(): # # first determine machine type # ret_dict = {} import os, string if os.name == 'nt': ret_dict['MACHINETYPE'] = 'PC' import win32api try: ret_dict['USERNAME'] = string.replace(win32api.GetUserName(), ' ', '_') except: ret_dict['USERNAME'] = '' proctype = win32api.GetSystemInfo()[6] if ` proctype ` [-2:] == '86': ret_dict['PROCESSORTYPE'] = 'intel' else: ret_dict['PROCESSORTYPE'] = 'alpha' gvex = win32api.GetVersionEx() if gvex[3] == 1: ret_dict['OPSYSTEM'] = '9X' ret_dict['USERDIRECTORY'] = '' else: ret_dict['OPSYSTEM'] = 'NT' ret_dict['USERDIRECTORY'] = os.environ['USERPROFILE'] ret_dict['OPVERSION'] = ` gvex[0] ` + '.' + ` gvex[1] `
def getWinOsType(self): name = self.UNKNOWN version = '' try: versionTupple = win32api.GetVersionEx(1) key = "%d.%d.%d" % (versionTupple[3], versionTupple[0], versionTupple[1]) version = '%d.%d' % versionTupple[:2] if key in self.winVersionMatrix: name = self.winVersionMatrix[key] # Window 7 and Window Server 2008 R2 share the same version. # Need to fix it using the wProductType field. VER_NT_WORKSTATION = 1 if (name == WinOsTypeHandler.WIN2008R2 and versionTupple[8] == VER_NT_WORKSTATION): name = WinOsTypeHandler.WIN7 elif (name == WinOsTypeHandler.WIN2012 and versionTupple[8] == VER_NT_WORKSTATION): name = WinOsTypeHandler.WIN8 logging.debug( "WinOsTypeHandler::getWinOsType osType = '%s' " "version = '%s'", name, version) except: logging.exception("getWinOsType - failed") return {'name': name, 'version': version}
def os_version_string(self): import win32api #platform: try to identify windows version vers = { "10.0": "Windows 10", "6.2": "Windows 8->10", "6.1": "Windows 7", "6.0": "Windows Vista", "5.2": "Windows XP 64-Bit", "5.1": "Windows XP", "5.0": "Windows 2000", } (pform, pver, build, _, _) = win32api.GetVersionEx() return vers.get( str(pform) + "." + str(pver), "Win32 (Unknown %i.%i)" % (pform, pver)) + " " + str(win32api.GetVersionEx())
def gui_save_file(self, start_dir=None, default_name=None, types=[]): import win32gui import win32api (pform, _, _, _, _) = win32api.GetVersionEx() typestrs = "" custom = "%s\0*.%s\0" % (types[0][0], types[0][1]) for desc, ext in types[1:]: typestrs += "%s\0%s\0" % (desc, "*.%s" % ext) if pform > 5: typestrs = "%s\0%s\0" % (types[0][0], "*.%s" % types[0][1]) + \ typestrs if not typestrs: typestrs = custom custom = None def_ext = "*.%s" % types[0][1] try: fname, _, _ = win32gui.GetSaveFileNameW(File=default_name, CustomFilter=custom, DefExt=def_ext, Filter=typestrs) except Exception, e: print "Failed to get filename: %s" % e return None
def system_information(): ''' Report system versions. ''' def system_version(): ''' Return host system version. ''' lin_ver = linux_distribution() mac_ver = platform.mac_ver() win_ver = platform.win32_ver() if lin_ver[0]: return u' '.join(lin_ver) elif mac_ver[0]: if isinstance(mac_ver[1], (tuple, list)) and u''.join(mac_ver[1]): return u' '.join( [mac_ver[0], u'.'.join(mac_ver[1]), mac_ver[2]]) else: return u' '.join([mac_ver[0], mac_ver[2]]) elif win_ver[0]: return u' '.join(win_ver) else: return u'' version = system_version() release = platform.release() if platform.win32_ver()[0]: import win32api # pylint: disable=3rd-party-module-not-gated server = { u'Vista': u'2008Server', u'7': u'2008ServerR2', u'8': u'2012Server', u'8.1': u'2012ServerR2', u'10': u'2016Server' } # Starting with Python 2.7.12 and 3.5.2 the `platform.uname()` function # started reporting the Desktop version instead of the Server version on # Server versions of Windows, so we need to look those up # So, if you find a Server Platform that's a key in the server # dictionary, then lookup the actual Server Release. # If this is a Server Platform then `GetVersionEx` will return a number # greater than 1. if win32api.GetVersionEx(1)[8] > 1 and release in server: release = server[release] _, ver, sp, extra = platform.win32_ver() version = ' '.join([release, ver, sp, extra]) system = [ (u'system', platform.system()), (u'dist', u' '.join(linux_distribution(full_distribution_name=False))), (u'release', release), (u'machine', platform.machine()), (u'version', version), (u'locale', locale.getpreferredencoding()), ] for name, attr in system: yield name, attr continue
def isWinNT(self): """Are we running in Windows NT?""" if self.getType() == 'win32': import win32api, win32con return win32api.GetVersionEx()[3] == win32con.VER_PLATFORM_WIN32_NT else: raise ValueError, "this is not a Windows platform"
def system_information(): ''' Report system versions. ''' def system_version(): ''' Return host system version. ''' lin_ver = linux_distribution() mac_ver = platform.mac_ver() win_ver = platform.win32_ver() if lin_ver[0]: return ' '.join(lin_ver) elif mac_ver[0]: if isinstance(mac_ver[1], (tuple, list)) and ''.join(mac_ver[1]): return ' '.join([mac_ver[0], '.'.join(mac_ver[1]), mac_ver[2]]) else: return ' '.join([mac_ver[0], mac_ver[2]]) elif win_ver[0]: return ' '.join(win_ver) else: return '' version = system_version() release = platform.release() if platform.win32_ver()[0]: import win32api # pylint: disable=3rd-party-module-not-gated if ((sys.version_info.major == 2 and sys.version_info >= (2, 7, 12)) or (sys.version_info.major == 3 and sys.version_info >= (3, 5, 2))): if win32api.GetVersionEx(1)[8] > 1: server = { 'Vista': '2008Server', '7': '2008ServerR2', '8': '2012Server', '8.1': '2012ServerR2', '10': '2016Server' } release = server.get(platform.release(), 'UNKServer') _, ver, sp, extra = platform.win32_ver() version = ' '.join([release, ver, sp, extra]) system = [ ('system', platform.system()), ('dist', ' '.join(linux_distribution(full_distribution_name=False))), ('release', release), ('machine', platform.machine()), ('version', version), ('locale', locale.getpreferredencoding()), ] for name, attr in system: yield name, attr continue
def os_version_string(self): import win32api vers = {4: "Win2k", 5: "WinXP", 6: "WinVista/7", } (pform, sub, build, _, _) = win32api.GetVersionEx() return vers.get(pform, "Win32 (Unknown %i.%i:%i)" % (pform, sub, build))
def InitInstance(self): " Called to crank up the app " numMRU = win32ui.GetProfileVal("Settings", "Recent File List Size", 10) win32ui.LoadStdProfileSettings(numMRU) # self._obj_.InitMDIInstance() if win32api.GetVersionEx()[0] < 4: win32ui.SetDialogBkColor() win32ui.Enable3dControls() # install a "callback caller" - a manager for the callbacks # self.oldCallbackCaller = win32ui.InstallCallbackCaller(self.CallbackManager) self.LoadMainFrame() self.SetApplicationPaths()
def os_version_string(self): import win32api vers = { 4: "Windows 2000", 5: "Windows XP", 6: "Windows Vista", 7: "Windows 7", } (pform, _, build, _, _) = win32api.GetVersionEx() return vers.get(pform, "Win32 (Unknown %i:%i)" % (pform, build))
def ShowBalloon(ret_code, balloon_info, hwnd=None, wait=False): if sys.platform.startswith("win"): # no hwnd supplied - find it if hwnd is None: try: hwnd = win32gui.FindWindow('ClamWinTrayWindow', 'ClamWin') except: return try: if balloon_info[0] is None: tuple = balloon_info[1] elif balloon_info[1] is None: tuple = balloon_info[0] elif ret_code == balloon_info[0][1]: tuple = balloon_info[0] elif ret_code != balloon_info[1][1]: tuple = balloon_info[1] else: return title = 'ClamWin Free Antivirus' txt = tuple[0] icon = tuple[2] timeout = tuple[3] # there is not balloon tips on windows 95/98/NT # (windows ME with balloons implemented has version 4.9) # need to display custom notification version = win32api.GetVersionEx() if version[0] == 4 and version[1] < 90: if icon == win32gui.NIIF_INFO: icon = win32con.IDI_INFORMATION elif icon == win32gui.NIIF_WARNING: icon = win32con.IDI_WARNING elif icon == win32gui.NIIF_ERROR: icon = win32con.IDI_ERROR elif icon == win32gui.NIIF_NONE: icon = 0 _ShowOwnBalloon(title, txt, icon, hwnd, timeout) if wait: i = 0 while i < timeout / 500: win32gui.PumpWaitingMessages() time.sleep(0.5) i += 1 else: nid = (hwnd, 0, win32gui.NIF_INFO, 0, 0, "", txt, timeout, title, icon) win32gui.Shell_NotifyIcon(win32gui.NIM_MODIFY, nid) except Exception, e: print 'Could not display notification. Error: %s' % str(e)
def GetExcludeSysLockedFiles(): configDir = os.path.join(win32api.GetSystemDirectory(), 'config') regFiles = ('default', 'SAM', 'SECURITY', 'software', 'software.alt', 'system', 'system.alt') ret = '' for regFile in regFiles: ret += ' --exclude="%s"' % os.path.join(configDir, regFile).replace( '\\', '\\\\') # add --exlude=win386.swp to fix the bug 939877 # see http://sourceforge.net/tracker/index.php?func=detail&aid=939877&group_id=105508&atid=641462 if win32api.GetVersionEx()[3] == win32con.VER_PLATFORM_WIN32_WINDOWS: ret += ' --exclude=win386.swp --exclude=pagefile.sys' return ret
def get_version_os(): """This method print out the system's hostname and come across the os""" version_os = platform.system() hostname = platform.node() print(hostname) if version_os == "Windows": version_data = win32api.GetVersionEx() version_number_windows = str(version_data[0]) + "." + str( version_data[1]) select_version_windows(version_number_windows) elif version_os == "Linux": print("Linux" + platform.release()) else: print("OS unknown")
def __init__(self): _version = platform.version().split('.') if len(_version) == 2: self.major = int(_version[0]) self.minor = int(_version[1]) self.build = 0 else: self.major = int(_version[0]) self.minor = int(_version[1]) self.build = int(_version[2]) self.wProductType = win32api.GetVersionEx(1)[8] self.wProcessorArchitecture = win32api.GetSystemInfo()[0] self.bits = 64 if platform.machine().endswith('64') else 32 _v = self.version self.version_full = _v.full self.version_short = _v.short self.server = _v.server
def populate_scaninfo(report): import socket import datetime report.add_info_item('hostname', socket.gethostname()) report.add_info_item('datetime', datetime.datetime.now().strftime("%Y-%m-%d %H:%M")) report.add_info_item('version', wpc.utils.get_version()) report.add_info_item( 'user', os.environ['USERDOMAIN'] + "\\" + os.environ['USERNAME']) report.add_info_item('domain', win32api.GetDomainName()) ver_list = win32api.GetVersionEx(1) try: report.add_info_item('ipaddress', ",".join( socket.gethostbyname_ex(socket.gethostname()) [2])) # have to do this before Wow64DisableWow64FsRedirection except: report.add_info_item( 'ipaddress', "<unknown>" ) # have to do this before Wow64DisableWow64FsRedirection os_ver = str(ver_list[0]) + "." + str(ver_list[1]) # version numbers from http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx if os_ver == "4.0": os_str = "Windows NT" if os_ver == "5.0": os_str = "Windows 2000" if os_ver == "5.1": os_str = "Windows XP" if os_ver == "5.2": os_str = "Windows 2003" if os_ver == "6.0": os_str = "Windows Vista" if os_ver == "6.0": os_str = "Windows 2008" if os_ver == "6.1": os_str = "Windows 2008 R2" if os_ver == "6.1": os_str = "Windows 7" report.add_info_item('os', os_str) report.add_info_item( 'os_version', str(ver_list[0]) + "." + str(ver_list[1]) + "." + str(ver_list[2]) + " SP" + str(ver_list[5]))
class Version: major, minor, build, platform, servpack = win32api.GetVersionEx() platformstr = {win32con.VER_PLATFORM_WIN32_WINDOWS:'Win9x', win32con.VER_PLATFORM_WIN32_NT:'NT'} def __repr__(self): return '%d, %d, %d, %s, %s ' % (Version.major, Version.minor, Version.build, \ Version.platformstr[Version.platform], Version.servpack) def isWin9x(self): return Version.platform == win32con.VER_PLATFORM_WIN32_WINDOWS and \ Version.major == 4 and Version.minor in (0, 10, 90) def isNT(self): return Version.platform == win32con.VER_PLATFORM_WIN32_NT def isWin95(self): return Version.platform == win32con.VER_PLATFORM_WIN32_WINDOWS and\ Version.major == 4 and Version.minor == 0 def isWin98(self): return Version.platform == win32con.VER_PLATFORM_WIN32_WINDOWS and\ Version.major == 4 and Version.minor == 10 def isWinMe(self): return Version.platform == win32con.VER_PLATFORM_WIN32_WINDOWS and\ Version.major == 4 and Version.minor == 90 def isNT4(self): return Version.platform == win32con.VER_PLATFORM_WIN32_NT and\ Version.major == 4 and Version.minor == 0 def isWin2k(self): return Version.platform == win32con.VER_PLATFORM_WIN32_NT and\ Version.major == 5 and Version.minor == 0 def isWinXP(self): return Version.platform == win32con.VER_PLATFORM_WIN32_NT and\ Version.major == 5 and Version.minor == 1
def getWindowsVersion(): return win32api.GetVersionEx()
def __init__(self, config=None): log.debug("GameEngine class init (GameEngine.py)...") self.mainMenu = None #placeholder for main menu object - to prevent reinstantiation self.currentScene = None self.versionString = version #stump: other version stuff moved to allow full version string to be retrieved without instantiating GameEngine self.uploadVersion = "%s-4.0" % Version.PROGRAM_NAME #akedrou - the version passed to the upload site. self.dataPath = Version.dataPath() log.debug(self.versionString + " starting up...") log.debug("Python version: " + sys.version.split(' ')[0]) log.debug("Pygame version: " + str(pygame.version.ver)) log.debug("PyOpenGL version: " + OpenGL.__version__) log.debug("Numpy version: " + np.__version__) log.debug("PIL version: " + Image.VERSION) log.debug("sys.argv: " + repr(sys.argv)) log.debug("os.name: " + os.name) log.debug("sys.platform: " + sys.platform) if os.name == 'nt': import win32api log.debug("win32api.GetVersionEx(1): " + repr(win32api.GetVersionEx(1))) elif os.name == 'posix': log.debug("os.uname(): " + repr(os.uname())) """ Constructor. @param config: L{Config} instance for settings """ self.tutorialFolder = "tutorials" if config is None: config = Config.load() self.config = config self.fps = self.config.get("video", "fps") self.running = True self.clock = FpsTimer() self.tickDelta = 0 self.task = TaskEngine(self) # Compatiblity task management self.addTask = self.task.addTask self.removeTask = self.task.removeTask self.pauseTask = self.task.pauseTask self.resumeTask = self.task.resumeTask self.title = self.versionString self.restartRequested = False # Load window icon icon = os.path.join(Version.dataPath(), "fofix_icon.png") self.video = Video(self.title, icon) if self.config.get("video", "disable_screensaver"): self.video.disableScreensaver() self.audio = Audio() self.fpsEstimate = 0 self.priority = self.config.get("engine", "highpriority") self.show_fps = self.config.get("video", "show_fps") self.advSettings = self.config.get("game", "adv_settings") self.restartRequired = False self.quicksetRestart = False self.quicksetPerf = self.config.get("quickset", "performance") self.scrollRate = self.config.get("game", "scroll_rate") self.scrollDelay = self.config.get("game", "scroll_delay") log.debug("Initializing audio.") frequency = self.config.get("audio", "frequency") bits = self.config.get("audio", "bits") stereo = self.config.get("audio", "stereo") bufferSize = self.config.get("audio", "buffersize") self.audio.open(frequency=frequency, bits=bits, stereo=stereo, bufferSize=bufferSize) self.gameStarted = False self.world = None self.audioSpeedFactor = 1.0 log.debug("Initializing video.") #myfingershurt: ensuring windowed mode starts up in center of the screen instead of cascading positions: os.environ['SDL_VIDEO_WINDOW_POS'] = 'center' width, height = [ int(s) for s in self.config.get("video", "resolution").split("x") ] fullscreen = self.config.get("video", "fullscreen") multisamples = self.config.get("video", "multisamples") self.video.setMode((width, height), fullscreen=fullscreen, multisamples=multisamples) log.debug("OpenGL version: " + glGetString(GL_VERSION)) log.debug("OpenGL vendor: " + glGetString(GL_VENDOR)) log.debug("OpenGL renderer: " + glGetString(GL_RENDERER)) log.debug("OpenGL extensions: " + ' '.join(sorted(glGetString(GL_EXTENSIONS).split()))) if self.video.default: self.config.set("video", "fullscreen", False) self.config.set("video", "resolution", "800x600") if self.config.get("video", "shader_use"): shaders.set(os.path.join(Version.dataPath(), "shaders")) # Enable the high priority timer if configured if self.priority: log.debug("Enabling high priority timer.") self.fps = 0 # High priority # evilynux - This was generating an error on the first pass (at least under # GNU/Linux) as the Viewport was not set yet. try: viewport = glGetIntegerv(GL_VIEWPORT) except Exception: viewport = [0, 0, width, height] h = viewport[3] - viewport[1] w = viewport[2] - viewport[0] geometry = (0, 0, w, h) self.svg = SvgContext(geometry) glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3])) self.startupMessages = self.video.error self.input = Input() self.view = View(self, geometry) self.resizeScreen(w, h) self.resource = Resource(Version.dataPath()) self.mainloop = self.loading self.menuMusic = False self.setlistMsg = None # Init theme system themename = self.config.get("coffee", "themename") themepath = os.path.join(Version.dataPath(), "themes", themename) self._initTheme(themename, themepath) self._initStages() # Load game modifications Mod.init(self) self.task.addTask(self.input, synced=False) self.task.addTask(self.view, synced=False) self.task.addTask(self.resource, synced=False) self.data = Data(self.resource, self.svg) self.input.addKeyListener(FullScreenSwitcher(self), priority=True) self.input.addSystemEventListener(SystemEventHandler(self)) self.debugLayer = None self.startupLayer = None self.loadingScreenShown = False self.graphicMenuShown = False log.debug("Ready.")
def getwindowsversion(): import win32api return win32api.GetVersionEx(0)
def __init__(self, mini_installer_path, previous_version_mini_installer_path, chromedriver_path, quiet, output_dir): """Constructor. The constructor initializes a variable dictionary that maps variables to their values. These are the only acceptable variables: * $BRAND: the browser brand (e.g., "Google Chrome" or "Chromium"). * $CHROME_DIR: the directory of Chrome (or Chromium) from the base installation directory. * $CHROME_HTML_PROG_ID: 'ChromeHTML' (or 'ChromiumHTM'). * $CHROME_LONG_NAME: 'Google Chrome' (or 'Chromium'). * $CHROME_LONG_NAME_BETA: 'Google Chrome Beta' if $BRAND is 'Google * Chrome'. * $CHROME_LONG_NAME_DEV: 'Google Chrome Dev' if $BRAND is 'Google * Chrome'. * $CHROME_LONG_NAME_SXS: 'Google Chrome SxS' if $BRAND is 'Google * Chrome'. * $CHROME_SHORT_NAME: 'Chrome' (or 'Chromium'). * $CHROME_SHORT_NAME_BETA: 'ChromeBeta' if $BRAND is 'Google Chrome'. * $CHROME_SHORT_NAME_DEV: 'ChromeDev' if $BRAND is 'Google Chrome'. * $CHROME_SHORT_NAME_SXS: 'ChromeCanary' if $BRAND is 'Google Chrome'. * $CHROME_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of Chrome for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_DEV: the registry key, excluding the root key, of Chrome Dev for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_BETA: the registry key, excluding the root key, of Chrome Beta for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_SXS: the registry key, excluding the root key, of Chrome SxS for Google Update. * $CHROMEDRIVER_PATH: Path to chromedriver. * $QUIET: Supress output. * $OUTPUT_DIR: "--output-dir=DIR" or an empty string. * $LAUNCHER_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of the app launcher for Google Update if $BRAND is 'Google * Chrome'. * $LOCAL_APPDATA: the unquoted path to the Local Application Data folder. * $LOG_FILE: "--log-file=FILE" or an empty string. * $MINI_INSTALLER: the unquoted path to the mini_installer. * $MINI_INSTALLER_BITNESS: the bitness of the mini_installer. * $MINI_INSTALLER_FILE_VERSION: the file version of $MINI_INSTALLER. * $PREVIOUS_VERSION_MINI_INSTALLER: the unquoted path to a mini_installer whose version is lower than $MINI_INSTALLER. * $PREVIOUS_VERSION_MINI_INSTALLER_FILE_VERSION: the file version of $PREVIOUS_VERSION_MINI_INSTALLER. * $PROGRAM_FILES: the unquoted path to the Program Files folder. * $USER_SPECIFIC_REGISTRY_SUFFIX: the output from the function _GetUserSpecificRegistrySuffix(). * $VERSION_[XP/SERVER_2003/VISTA/WIN7/WIN8/WIN8_1/WIN10]: a 2-tuple representing the version of the corresponding OS. * $WINDOWS_VERSION: a 2-tuple representing the current Windows version. * $CHROME_TOAST_ACTIVATOR_CLSID: NotificationActivator's CLSID for Chrome. * $CHROME_TOAST_ACTIVATOR_CLSID_BETA: NotificationActivator's CLSID for Chrome Beta. * $CHROME_TOAST_ACTIVATOR_CLSID_DEV: NotificationActivator's CLSID for Chrome Dev. * $CHROME_TOAST_ACTIVATOR_CLSID_SXS: NotificationActivator's CLSID for Chrome SxS. * $CHROME_ELEVATOR_CLSID: Elevator Service CLSID for Chrome. * $CHROME_ELEVATOR_CLSID_BETA: Elevator Service CLSID for Chrome Beta. * $CHROME_ELEVATOR_CLSID_DEV: Elevator Service CLSID for Chrome Dev. * $CHROME_ELEVATOR_CLSID_SXS: Elevator Service CLSID for Chrome SxS. * $CHROME_ELEVATOR_IID: IElevator IID for Chrome. * $CHROME_ELEVATOR_IID_BETA: IElevator IID for Chrome Beta. * $CHROME_ELEVATOR_IID_DEV: IElevator IID for Chrome Dev. * $CHROME_ELEVATOR_IID_SXS: IElevator IID for Chrome SxS. * $CHROME_ELEVATION_SERVICE_NAME: Elevation Service Name for Chrome. * $CHROME_ELEVATION_SERVICE_NAME_BETA: Elevation Service Name for Chrome Beta. * $CHROME_ELEVATION_SERVICE_NAME_DEV: Elevation Service Name for Chrome Dev. * $CHROME_ELEVATION_SERVICE_NAME_SXS: Elevation Service Name for Chrome SxS. * $CHROME_ELEVATION_SERVICE_DISPLAY_NAME: Elevation Service Display Name for Chrome. * $CHROME_ELEVATION_SERVICE_DISPLAY_NAME_BETA: Elevation Service Display Name for Chrome Beta. * $CHROME_ELEVATION_SERVICE_DISPLAY_NAME_DEV: Elevation Service Display Name for Chrome Dev. * $CHROME_ELEVATION_SERVICE_DISPLAY_NAME_SXS: Elevation Service Display Name for Chrome SxS. Args: mini_installer_path: The path to a mini_installer. previous_version_mini_installer_path: The path to a mini_installer whose version is lower than |mini_installer_path|. """ mini_installer_abspath = os.path.abspath(mini_installer_path) previous_version_mini_installer_abspath = os.path.abspath( previous_version_mini_installer_path) windows_major_ver, windows_minor_ver, _, _, _ = win32api.GetVersionEx() self._variable_mapping = { 'CHROMEDRIVER_PATH': chromedriver_path, 'QUIET': '-q' if quiet else '', 'OUTPUT_DIR': '"--output-dir=%s"' % output_dir if output_dir else '', 'LOCAL_APPDATA': shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, None, 0), 'LOG_FILE': '', 'MINI_INSTALLER': mini_installer_abspath, 'MINI_INSTALLER_FILE_VERSION': _GetFileVersion(mini_installer_abspath), 'MINI_INSTALLER_BITNESS': _GetFileBitness(mini_installer_abspath), 'PREVIOUS_VERSION_MINI_INSTALLER': previous_version_mini_installer_abspath, 'PREVIOUS_VERSION_MINI_INSTALLER_FILE_VERSION': _GetFileVersion(previous_version_mini_installer_abspath), 'PROGRAM_FILES': shell.SHGetFolderPath( 0, shellcon.CSIDL_PROGRAM_FILES if _GetFileBitness(mini_installer_abspath) == '64' else shellcon.CSIDL_PROGRAM_FILESX86, None, 0), 'USER_SPECIFIC_REGISTRY_SUFFIX': _GetUserSpecificRegistrySuffix(), 'VERSION_SERVER_2003': '(5, 2)', 'VERSION_VISTA': '(6, 0)', 'VERSION_WIN10': '(10, 0)', 'VERSION_WIN7': '(6, 1)', 'VERSION_WIN8': '(6, 2)', 'VERSION_WIN8_1': '(6, 3)', 'VERSION_XP': '(5, 1)', 'WINDOWS_VERSION': '(%s, %s)' % (windows_major_ver, windows_minor_ver) } mini_installer_product_name = _GetProductName(mini_installer_abspath) if mini_installer_product_name == 'Google Chrome Installer': self._variable_mapping.update({ 'BRAND': 'Google Chrome', 'BINARIES_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}'), 'CHROME_DIR': 'Google\\Chrome', 'CHROME_HTML_PROG_ID': 'ChromeHTML', 'CHROME_HTML_PROG_ID_BETA': 'ChromeBHTML', 'CHROME_HTML_PROG_ID_DEV': 'ChromeDHTML', 'CHROME_HTML_PROG_ID_SXS': 'ChromeSSHTM', 'CHROME_LONG_NAME': 'Google Chrome', 'CHROME_SHORT_NAME': 'Chrome', 'CHROME_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), 'CHROME_CLIENT_STATE_KEY': ('Software\\Google\\Update\\ClientState\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), 'CHROME_TOAST_ACTIVATOR_CLSID': ('{A2C6CB58-C076-425C-ACB7-6D19D64428CD}'), 'CHROME_DIR_BETA': 'Google\\Chrome Beta', 'CHROME_DIR_DEV': 'Google\\Chrome Dev', 'CHROME_DIR_SXS': 'Google\\Chrome SxS', 'CHROME_LONG_NAME_BETA': 'Google Chrome Beta', 'CHROME_LONG_NAME_DEV': 'Google Chrome Dev', 'CHROME_LONG_NAME_SXS': 'Google Chrome SxS', 'CHROME_SHORT_NAME_BETA': 'ChromeBeta', 'CHROME_SHORT_NAME_DEV': 'ChromeDev', 'CHROME_SHORT_NAME_SXS': 'ChromeCanary', 'CHROME_UPDATE_REGISTRY_SUBKEY_BETA': ('Software\\Google\\Update\\Clients\\' '{8237E44A-0054-442C-B6B6-EA0509993955}'), 'CHROME_UPDATE_REGISTRY_SUBKEY_DEV': ('Software\\Google\\Update\\Clients\\' '{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}'), 'CHROME_UPDATE_REGISTRY_SUBKEY_SXS': ('Software\\Google\\Update\\Clients\\' '{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}'), 'LAUNCHER_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}'), 'CHROME_TOAST_ACTIVATOR_CLSID_BETA': ('{B89B137F-96AA-4AE2-98C4-6373EAA1EA4D}'), 'CHROME_TOAST_ACTIVATOR_CLSID_DEV': ('{F01C03EB-D431-4C83-8D7A-902771E732FA}'), 'CHROME_TOAST_ACTIVATOR_CLSID_SXS': ('{FA372A6E-149F-4E95-832D-8F698D40AD7F}'), 'CHROME_ELEVATOR_CLSID': ('{708860E0-F641-4611-8895-7D867DD3675B}'), 'CHROME_ELEVATOR_CLSID_BETA': ('{DD2646BA-3707-4BF8-B9A7-038691A68FC2}'), 'CHROME_ELEVATOR_CLSID_DEV': ('{DA7FDCA5-2CAA-4637-AA17-0740584DE7DA}'), 'CHROME_ELEVATOR_CLSID_SXS': ('{704C2872-2049-435E-A469-0A534313C42B}'), 'CHROME_ELEVATOR_IID': ('{463ABECF-410D-407F-8AF5-0DF35A005CC8}'), 'CHROME_ELEVATOR_IID_BETA': ('{A2721D66-376E-4D2F-9F0F-9070E9A42B5F}'), 'CHROME_ELEVATOR_IID_DEV': ('{BB2AA26B-343A-4072-8B6F-80557B8CE571}'), 'CHROME_ELEVATOR_IID_SXS': ('{4F7CE041-28E9-484F-9DD0-61A8CACEFEE4}'), 'CHROME_ELEVATION_SERVICE_NAME': ('GoogleChromeElevationService'), 'CHROME_ELEVATION_SERVICE_NAME_BETA': ('GoogleChromeBetaElevationService'), 'CHROME_ELEVATION_SERVICE_NAME_DEV': ('GoogleChromeDevElevationService'), 'CHROME_ELEVATION_SERVICE_NAME_SXS': ('GoogleChromeCanaryElevationService'), 'CHROME_ELEVATION_SERVICE_DISPLAY_NAME': ('Google Chrome Elevation Service (GoogleChromeElevationService)' ), 'CHROME_ELEVATION_SERVICE_DISPLAY_NAME_BETA': ('Google Chrome Beta Elevation Service' ' (GoogleChromeBetaElevationService)'), 'CHROME_ELEVATION_SERVICE_DISPLAY_NAME_DEV': ('Google Chrome Dev Elevation Service' ' (GoogleChromeDevElevationService)'), 'CHROME_ELEVATION_SERVICE_DISPLAY_NAME_SXS': ('Google Chrome Canary Elevation Service' ' (GoogleChromeCanaryElevationService)'), }) elif mini_installer_product_name == 'Chromium Installer': self._variable_mapping.update({ 'BRAND': 'Chromium', 'BINARIES_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium Binaries', 'CHROME_DIR': 'Chromium', 'CHROME_HTML_PROG_ID': 'ChromiumHTM', 'CHROME_LONG_NAME': 'Chromium', 'CHROME_SHORT_NAME': 'Chromium', 'CHROME_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium', 'CHROME_CLIENT_STATE_KEY': 'Software\\Chromium', 'CHROME_TOAST_ACTIVATOR_CLSID': ('{635EFA6F-08D6-4EC9-BD14-8A0FDE975159}'), 'CHROME_ELEVATOR_CLSID': ('{D133B120-6DB4-4D6B-8BFE-83BF8CA1B1B0}'), 'CHROME_ELEVATOR_IID': ('{B88C45B9-8825-4629-B83E-77CC67D9CEED}'), 'CHROME_ELEVATION_SERVICE_NAME': 'ChromiumElevationService', 'CHROME_ELEVATION_SERVICE_DISPLAY_NAME': ('Chromium Elevation Service (ChromiumElevationService)'), }) else: raise KeyError("Unknown mini_installer product name '%s'" % mini_installer_product_name)
def __init__(self, config = None): log.debug("GameEngine class init (GameEngine.py)...") self.mainMenu = None #placeholder for main menu object - to prevent reinstantiation self.currentScene = None self.versionString = version #stump: other version stuff moved to allow full version string to be retrieved without instantiating GameEngine self.uploadVersion = "%s-4.0" % Version.PROGRAM_NAME #akedrou - the version passed to the upload site. self.dataPath = Version.dataPath() log.debug(self.versionString + " starting up...") log.debug("Python version: " + sys.version.split(' ')[0]) log.debug("Pygame version: " + str(pygame.version.ver) ) log.debug("PyOpenGL version: " + OpenGL.__version__) log.debug("Numpy version: " + np.__version__) log.debug("PIL version: " + Image.VERSION) log.debug("sys.argv: " + repr(sys.argv)) log.debug("os.name: " + os.name) log.debug("sys.platform: " + sys.platform) if os.name == 'nt': import win32api log.debug("win32api.GetVersionEx(1): " + repr(win32api.GetVersionEx(1))) elif os.name == 'posix': log.debug("os.uname(): " + repr(os.uname())) """ Constructor. @param config: L{Config} instance for settings """ self.tutorialFolder = "tutorials" if not config: config = Config.load() self.config = config self.fps = self.config.get("video", "fps") self.running = True self.clock = FpsTimer() self.tickDelta = 0 self.task = TaskEngine(self) # Compatiblity task management self.addTask = self.task.addTask self.removeTask = self.task.removeTask self.pauseTask = self.task.pauseTask self.resumeTask = self.task.resumeTask self.title = self.versionString self.restartRequested = False # evilynux - Check if theme icon exists first, then fallback on FoFiX icon. themename = self.config.get("coffee", "themename") themeicon = os.path.join(Version.dataPath(), "themes", themename, "icon.png") fofixicon = os.path.join(Version.dataPath(), "fofix_icon.png") icon = None if os.path.exists(themeicon): icon = themeicon elif os.path.exists(fofixicon): icon = fofixicon self.video = Video(self.title, icon) if self.config.get("video", "disable_screensaver"): self.video.disableScreensaver() self.audio = Audio() self.fpsEstimate = 0 self.priority = self.config.get("engine", "highpriority") self.show_fps = self.config.get("video", "show_fps") self.advSettings = self.config.get("game", "adv_settings") self.restartRequired = False self.quicksetRestart = False self.quicksetPerf = self.config.get("quickset", "performance") self.scrollRate = self.config.get("game", "scroll_rate") self.scrollDelay = self.config.get("game", "scroll_delay") log.debug("Initializing audio.") frequency = self.config.get("audio", "frequency") bits = self.config.get("audio", "bits") stereo = self.config.get("audio", "stereo") bufferSize = self.config.get("audio", "buffersize") self.audio.open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize) self.cmdPlay = 0 self.cmdMode = None self.cmdDiff = None self.cmdPart = None self.gameStarted = False self.world = None self.audioSpeedFactor = 1.0 log.debug("Initializing video.") #myfingershurt: ensuring windowed mode starts up in center of the screen instead of cascading positions: os.environ['SDL_VIDEO_WINDOW_POS'] = 'center' width, height = [int(s) for s in self.config.get("video", "resolution").split("x")] fullscreen = self.config.get("video", "fullscreen") multisamples = self.config.get("video", "multisamples") self.video.setMode((width, height), fullscreen = fullscreen, multisamples = multisamples) log.debug("OpenGL version: " + glGetString(GL_VERSION)) log.debug("OpenGL vendor: " + glGetString(GL_VENDOR)) log.debug("OpenGL renderer: " + glGetString(GL_RENDERER)) log.debug("OpenGL extensions: " + ' '.join(sorted(glGetString(GL_EXTENSIONS).split()))) if self.video.default: self.config.set("video", "fullscreen", False) self.config.set("video", "resolution", "800x600") if self.config.get("video", "shader_use"): shaders.set(os.path.join(Version.dataPath(), "shaders")) # Enable the high priority timer if configured if self.priority: log.debug("Enabling high priority timer.") self.fps = 0 # High priority # evilynux - This was generating an error on the first pass (at least under # GNU/Linux) as the Viewport was not set yet. try: viewport = glGetIntegerv(GL_VIEWPORT) except: viewport = [0, 0, width, height] h = viewport[3] - viewport[1] w = viewport[2] - viewport[0] geometry = (0, 0, w, h) self.svg = SvgContext(geometry) glViewport(int(viewport[0]), int(viewport[1]), int(viewport[2]), int(viewport[3])) self.startupMessages = self.video.error self.input = Input() self.view = View(self, geometry) self.resizeScreen(w, h) self.resource = Resource(Version.dataPath()) self.mainloop = self.loading self.menuMusic = False self.setlistMsg = None # Load game modifications Mod.init(self) self.task.addTask(self.input, synced = False) self.task.addTask(self.view, synced = False) self.task.addTask(self.resource, synced = False) self.data = Data(self.resource, self.svg) ##MFH: Animated stage folder selection option #<themename>\Stages still contains the backgrounds for when stage rotation is off, and practice.png #subfolders under Stages\ will each be treated as a separate animated stage set self.stageFolders = [] currentTheme = themename stagespath = os.path.join(Version.dataPath(), "themes", currentTheme, "backgrounds") themepath = os.path.join(Version.dataPath(), "themes", currentTheme) if os.path.exists(stagespath): self.stageFolders = [] allFolders = os.listdir(stagespath) #this also includes all the stage files - so check to see if there is at least one .png file inside each folder to be sure it's an animated stage folder for name in allFolders: aniStageFolderListing = [] thisIsAnAnimatedStageFolder = False try: aniStageFolderListing = os.listdir(os.path.join(stagespath,name)) except Exception: thisIsAnAnimatedStageFolder = False for aniFile in aniStageFolderListing: if os.path.splitext(aniFile)[1] in [".png", ".jpg", ".jpeg"]: # we've found at least one .png file here, chances are this is a valid animated stage folder thisIsAnAnimatedStageFolder = True if thisIsAnAnimatedStageFolder: self.stageFolders.append(name) i = len(self.stageFolders) if i > 0: #only set default to first animated subfolder if one exists - otherwise use Normal! defaultAniStage = str(self.stageFolders[0]) else: defaultAniStage = "Normal" log.debug("Default animated stage for " + currentTheme + " theme = " + defaultAniStage) aniStageOptions = dict([(str(self.stageFolders[n]),self.stageFolders[n]) for n in range(0, i)]) aniStageOptions.update({"Normal":_("Slideshow")}) if i > 1: #only add Random setting if more than one animated stage exists aniStageOptions.update({"Random":_("Random")}) Config.define("game", "animated_stage_folder", str, defaultAniStage, text = _("Animated Stage"), options = aniStageOptions ) #MFH: here, need to track and check a new ini entry for last theme - so when theme changes we can re-default animated stage to first found lastTheme = self.config.get("game","last_theme") if lastTheme == "" or lastTheme != currentTheme: #MFH - no last theme, and theme just changed: self.config.set("game","animated_stage_folder",defaultAniStage) #force defaultAniStage self.config.set("game","last_theme",currentTheme) selectedAnimatedStage = self.config.get("game", "animated_stage_folder") if selectedAnimatedStage != "Normal" and selectedAnimatedStage != "Random": if not os.path.exists(os.path.join(stagespath,selectedAnimatedStage)): log.warn("Selected animated stage folder " + selectedAnimatedStage + " does not exist, forcing Normal.") self.config.set("game","animated_stage_folder","Normal") #MFH: force "Standard" currently selected animated stage folder is invalid else: Config.define("game", "animated_stage_folder", str, "None", text = _("Animated Stage"), options = ["None",_("None")]) log.warn("No stages\ folder found, forcing None setting for Animated Stage.") self.config.set("game","animated_stage_folder", "None") #MFH: force "None" when Stages folder can't be found try: fp, pathname, description = imp.find_module("CustomTheme",[themepath]) theme = imp.load_module("CustomTheme", fp, pathname, description) self.theme = theme.CustomTheme(themepath, themename) except ImportError: self.theme = Theme(themepath, themename) self.task.addTask(self.theme) self.input.addKeyListener(FullScreenSwitcher(self), priority = True) self.input.addSystemEventListener(SystemEventHandler(self)) self.debugLayer = None self.startupLayer = None self.loadingScreenShown = False self.graphicMenuShown = False log.debug("Ready.")
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #----------------------------------------------------------------------------- import os, sys, time, tempfile, shutil, locale import Config, ConfigParser import re, fnmatch, urllib2 import _winreg import win32api, win32con, win32gui, win32event, win32con, pywintypes from win32com.shell import shell, shellcon if win32api.GetVersionEx()[3] != win32con.VER_PLATFORM_WIN32_WINDOWS: import win32security from ctypes import * from ctypes.wintypes import DWORD EM_AUTOURLDETECT = 1115 EM_HIDESELECTION = 1087 CONFIG_EVENT = 'ClamWinConfigUpdateEvent01' _FRESHCLAM_CONF_GENERAL = """ DNSDatabaseInfo current.cvd.clamav.net DatabaseMirror %s MaxAttempts 3 """ _FRESHCLAM_CONF_PROXY = """ HTTPProxyServer %s
def getWindowsVersion() -> typing.Tuple[int, int, int, int, str]: return win32api.GetVersionEx()
def get_windows_version(): """Get the Windows major and minor version in a decimal like 10.0""" v = win32api.GetVersionEx(0) vstr = '%d.%d' % (v[0], v[1]) return Decimal(vstr)
def __init__(self, mini_installer_path, previous_version_mini_installer_path, chromedriver_path, quiet): """Constructor. The constructor initializes a variable dictionary that maps variables to their values. These are the only acceptable variables: * $BRAND: the browser brand (e.g., "Google Chrome" or "Chromium"). * $CHROME_DIR: the directory of Chrome (or Chromium) from the base installation directory. * $CHROME_HTML_PROG_ID: 'ChromeHTML' (or 'ChromiumHTM'). * $CHROME_LONG_NAME: 'Google Chrome' (or 'Chromium'). * $CHROME_LONG_NAME_BETA: 'Google Chrome Beta' if $BRAND is 'Google * Chrome'. * $CHROME_LONG_NAME_DEV: 'Google Chrome Dev' if $BRAND is 'Google * Chrome'. * $CHROME_LONG_NAME_SXS: 'Google Chrome SxS' if $BRAND is 'Google * Chrome'. * $CHROME_SHORT_NAME: 'Chrome' (or 'Chromium'). * $CHROME_SHORT_NAME_BETA: 'ChromeBeta' if $BRAND is 'Google Chrome'. * $CHROME_SHORT_NAME_DEV: 'ChromeDev' if $BRAND is 'Google Chrome'. * $CHROME_SHORT_NAME_SXS: 'ChromeCanary' if $BRAND is 'Google Chrome'. * $CHROME_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of Chrome for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_DEV: the registry key, excluding the root key, of Chrome Dev for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_BETA: the registry key, excluding the root key, of Chrome Beta for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_SXS: the registry key, excluding the root key, of Chrome SxS for Google Update. * $CHROMEDRIVER_PATH: Path to chromedriver. * $QUIET: Supress output * $LAUNCHER_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of the app launcher for Google Update if $BRAND is 'Google * Chrome'. * $LOCAL_APPDATA: the unquoted path to the Local Application Data folder. * $MINI_INSTALLER: the unquoted path to the mini_installer. * $MINI_INSTALLER_BITNESS: the bitness of the mini_installer. * $MINI_INSTALLER_FILE_VERSION: the file version of $MINI_INSTALLER. * $PREVIOUS_VERSION_MINI_INSTALLER: the unquoted path to a mini_installer whose version is lower than $MINI_INSTALLER. * $PREVIOUS_VERSION_MINI_INSTALLER_FILE_VERSION: the file version of $PREVIOUS_VERSION_MINI_INSTALLER. * $PROGRAM_FILES: the unquoted path to the Program Files folder. * $USER_SPECIFIC_REGISTRY_SUFFIX: the output from the function _GetUserSpecificRegistrySuffix(). * $VERSION_[XP/SERVER_2003/VISTA/WIN7/WIN8/WIN8_1/WIN10]: a 2-tuple representing the version of the corresponding OS. * $WINDOWS_VERSION: a 2-tuple representing the current Windows version. * $CHROME_TOAST_ACTIVATOR_CLSID: NotificationActivator's CLSID for Chrome. * $CHROME_TOAST_ACTIVATOR_CLSID_BETA: NotificationActivator's CLSID for Chrome Beta. * $CHROME_TOAST_ACTIVATOR_CLSID_DEV: NotificationActivator's CLSID for Chrome Dev. * $CHROME_TOAST_ACTIVATOR_CLSID_SXS: NotificationActivator's CLSID for Chrome SxS. Args: mini_installer_path: The path to a mini_installer. previous_version_mini_installer_path: The path to a mini_installer whose version is lower than |mini_installer_path|. """ mini_installer_abspath = os.path.abspath(mini_installer_path) previous_version_mini_installer_abspath = os.path.abspath( previous_version_mini_installer_path) windows_major_ver, windows_minor_ver, _, _, _ = win32api.GetVersionEx() self._variable_mapping = { 'CHROMEDRIVER_PATH': chromedriver_path, 'QUIET': '-q' if quiet else '', 'LOCAL_APPDATA': shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, None, 0), 'MINI_INSTALLER': mini_installer_abspath, 'MINI_INSTALLER_FILE_VERSION': _GetFileVersion(mini_installer_abspath), 'MINI_INSTALLER_BITNESS': _GetFileBitness(mini_installer_abspath), 'PREVIOUS_VERSION_MINI_INSTALLER': previous_version_mini_installer_abspath, 'PREVIOUS_VERSION_MINI_INSTALLER_FILE_VERSION': _GetFileVersion(previous_version_mini_installer_abspath), 'PROGRAM_FILES': shell.SHGetFolderPath(0, shellcon.CSIDL_PROGRAM_FILESX86, None, 0), 'USER_SPECIFIC_REGISTRY_SUFFIX': _GetUserSpecificRegistrySuffix(), 'VERSION_SERVER_2003': '(5, 2)', 'VERSION_VISTA': '(6, 0)', 'VERSION_WIN10': '(10, 0)', 'VERSION_WIN7': '(6, 1)', 'VERSION_WIN8': '(6, 2)', 'VERSION_WIN8_1': '(6, 3)', 'VERSION_XP': '(5, 1)', 'WINDOWS_VERSION': '(%s, %s)' % (windows_major_ver, windows_minor_ver) } mini_installer_product_name = _GetProductName(mini_installer_abspath) if mini_installer_product_name == 'Google Chrome Installer': self._variable_mapping.update({ 'BRAND': 'Google Chrome', 'BINARIES_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}'), 'CHROME_DIR': 'Google\\Chrome', 'CHROME_HTML_PROG_ID': 'ChromeHTML', 'CHROME_HTML_PROG_ID_BETA': 'ChromeBHTML', 'CHROME_HTML_PROG_ID_DEV': 'ChromeDHTML', 'CHROME_HTML_PROG_ID_SXS': 'ChromeSSHTM', 'CHROME_LONG_NAME': 'Google Chrome', 'CHROME_SHORT_NAME': 'Chrome', 'CHROME_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), 'CHROME_CLIENT_STATE_KEY': ('Software\\Google\\Update\\ClientState\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), 'CHROME_TOAST_ACTIVATOR_CLSID': ('{A2C6CB58-C076-425C-ACB7-6D19D64428CD}'), 'CHROME_DIR_BETA': 'Google\\Chrome Beta', 'CHROME_DIR_DEV': 'Google\\Chrome Dev', 'CHROME_DIR_SXS': 'Google\\Chrome SxS', 'CHROME_LONG_NAME_BETA': 'Google Chrome Beta', 'CHROME_LONG_NAME_DEV': 'Google Chrome Dev', 'CHROME_LONG_NAME_SXS': 'Google Chrome SxS', 'CHROME_SHORT_NAME_BETA': 'ChromeBeta', 'CHROME_SHORT_NAME_DEV': 'ChromeDev', 'CHROME_SHORT_NAME_SXS': 'ChromeCanary', 'CHROME_UPDATE_REGISTRY_SUBKEY_BETA': ('Software\\Google\\Update\\Clients\\' '{8237E44A-0054-442C-B6B6-EA0509993955}'), 'CHROME_UPDATE_REGISTRY_SUBKEY_DEV': ('Software\\Google\\Update\\Clients\\' '{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}'), 'CHROME_UPDATE_REGISTRY_SUBKEY_SXS': ('Software\\Google\\Update\\Clients\\' '{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}'), 'LAUNCHER_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}'), 'CHROME_TOAST_ACTIVATOR_CLSID_BETA': ('{B89B137F-96AA-4AE2-98C4-6373EAA1EA4D}'), 'CHROME_TOAST_ACTIVATOR_CLSID_DEV': ('{F01C03EB-D431-4C83-8D7A-902771E732FA}'), 'CHROME_TOAST_ACTIVATOR_CLSID_SXS': ('{FA372A6E-149F-4E95-832D-8F698D40AD7F}'), }) elif mini_installer_product_name == 'Chromium Installer': self._variable_mapping.update({ 'BRAND': 'Chromium', 'BINARIES_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium Binaries', 'CHROME_DIR': 'Chromium', 'CHROME_HTML_PROG_ID': 'ChromiumHTM', 'CHROME_LONG_NAME': 'Chromium', 'CHROME_SHORT_NAME': 'Chromium', 'CHROME_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium', 'CHROME_CLIENT_STATE_KEY': 'Software\\Chromium', 'CHROME_TOAST_ACTIVATOR_CLSID': ('{635EFA6F-08D6-4EC9-BD14-8A0FDE975159}'), }) else: raise KeyError("Unknown mini_installer product name '%s'" % mini_installer_product_name)
def platform_windows_7(): #FIXME: Replace with proper test as soon as this issue is fixed in Python dist #See http://bugs.python.org/issue7863 maj, min, buildno, plat, csd = win32api.GetVersionEx() return maj == 6 and min == 1
def __init__(self, mini_installer_path, next_version_mini_installer_path): """Constructor. The constructor initializes a variable dictionary that maps variables to their values. These are the only acceptable variables: * $BRAND: the browser brand (e.g., "Google Chrome" or "Chromium"). * $CHROME_DIR: the directory of Chrome (or Chromium) from the base installation directory. * $CHROME_HTML_PROG_ID: 'ChromeHTML' (or 'ChromiumHTM'). * $CHROME_LONG_NAME: 'Google Chrome' (or 'Chromium'). * $CHROME_LONG_NAME_BETA: 'Google Chrome Beta' if $BRAND is 'Google * Chrome'. * $CHROME_LONG_NAME_DEV: 'Google Chrome Dev' if $BRAND is 'Google * Chrome'. * $CHROME_LONG_NAME_SXS: 'Google Chrome SxS' if $BRAND is 'Google * Chrome'. * $CHROME_SHORT_NAME: 'Chrome' (or 'Chromium'). * $CHROME_SHORT_NAME_BETA: 'ChromeBeta' if $BRAND is 'Google Chrome'. * $CHROME_SHORT_NAME_DEV: 'ChromeDev' if $BRAND is 'Google Chrome'. * $CHROME_SHORT_NAME_SXS: 'ChromeCanary' if $BRAND is 'Google Chrome'. * $CHROME_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of Chrome for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_DEV: the registry key, excluding the root key, of Chrome Dev for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_BETA: the registry key, excluding the root key, of Chrome Beta for Google Update. * $CHROME_UPDATE_REGISTRY_SUBKEY_SXS: the registry key, excluding the root key, of Chrome SxS for Google Update. * $LAUNCHER_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of the app launcher for Google Update if $BRAND is 'Google * Chrome'. * $LOCAL_APPDATA: the unquoted path to the Local Application Data folder. * $MINI_INSTALLER: the unquoted path to the mini_installer. * $MINI_INSTALLER_FILE_VERSION: the file version of $MINI_INSTALLER. * $NEXT_VERSION_MINI_INSTALLER: the unquoted path to a mini_installer whose version is higher than $MINI_INSTALLER. * $NEXT_VERSION_MINI_INSTALLER_FILE_VERSION: the file version of $NEXT_VERSION_MINI_INSTALLER. * $PROGRAM_FILES: the unquoted path to the Program Files folder. * $USER_SPECIFIC_REGISTRY_SUFFIX: the output from the function _GetUserSpecificRegistrySuffix(). * $VERSION_[XP/SERVER_2003/VISTA/WIN7/WIN8/WIN8_1/WIN10]: a 2-tuple representing the version of the corresponding OS. * $WINDOWS_VERSION: a 2-tuple representing the current Windows version. Args: mini_installer_path: The path to a mini_installer. next_version_mini_installer_path: The path to a mini_installer whose version is higher than |mini_installer_path|. """ mini_installer_abspath = os.path.abspath(mini_installer_path) next_version_mini_installer_abspath = os.path.abspath( next_version_mini_installer_path) windows_major_ver, windows_minor_ver, _, _, _ = win32api.GetVersionEx() self._variable_mapping = { 'LOCAL_APPDATA': shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, None, 0), 'MINI_INSTALLER': mini_installer_abspath, 'MINI_INSTALLER_FILE_VERSION': _GetFileVersion(mini_installer_abspath), 'NEXT_VERSION_MINI_INSTALLER': next_version_mini_installer_abspath, 'NEXT_VERSION_MINI_INSTALLER_FILE_VERSION': _GetFileVersion(next_version_mini_installer_abspath), 'PROGRAM_FILES': shell.SHGetFolderPath(0, shellcon.CSIDL_PROGRAM_FILES, None, 0), 'USER_SPECIFIC_REGISTRY_SUFFIX': _GetUserSpecificRegistrySuffix(), 'VERSION_SERVER_2003': '(5, 2)', 'VERSION_VISTA': '(6, 0)', 'VERSION_WIN10': '(10, 0)', 'VERSION_WIN7': '(6, 1)', 'VERSION_WIN8': '(6, 2)', 'VERSION_WIN8_1': '(6, 3)', 'VERSION_XP': '(5, 1)', 'WINDOWS_VERSION': '(%s, %s)' % (windows_major_ver, windows_minor_ver) } mini_installer_product_name = _GetProductName(mini_installer_abspath) if mini_installer_product_name == 'Google Chrome Installer': self._variable_mapping.update({ 'BRAND': 'Google Chrome', 'BINARIES_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}'), 'CHROME_DIR': 'Google\\Chrome', 'CHROME_HTML_PROG_ID': 'ChromeHTML', 'CHROME_LONG_NAME': 'Google Chrome', 'CHROME_SHORT_NAME': 'Chrome', 'CHROME_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), 'CHROME_CLIENT_STATE_KEY': ('Software\\Google\\Update\\ClientState\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}'), 'CHROME_DIR_BETA': 'Google\\Chrome Beta', 'CHROME_DIR_DEV': 'Google\\Chrome Dev', 'CHROME_DIR_SXS': 'Google\\Chrome SxS', 'CHROME_LONG_NAME_BETA': 'Google Chrome Beta', 'CHROME_LONG_NAME_DEV': 'Google Chrome Dev', 'CHROME_LONG_NAME_SXS': 'Google Chrome SxS', 'CHROME_SHORT_NAME_BETA': 'ChromeBeta', 'CHROME_SHORT_NAME_DEV': 'ChromeDev', 'CHROME_SHORT_NAME_SXS': 'ChromeCanary', 'CHROME_UPDATE_REGISTRY_SUBKEY_BETA': ('Software\\Google\\Update\\Clients\\' '{8237E44A-0054-442C-B6B6-EA0509993955}'), 'CHROME_UPDATE_REGISTRY_SUBKEY_DEV': ('Software\\Google\\Update\\Clients\\' '{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}'), 'CHROME_UPDATE_REGISTRY_SUBKEY_SXS': ('Software\\Google\\Update\\Clients\\' '{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}'), 'LAUNCHER_UPDATE_REGISTRY_SUBKEY': ('Software\\Google\\Update\\Clients\\' '{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}') }) elif mini_installer_product_name == 'Chromium Installer': self._variable_mapping.update({ 'BRAND': 'Chromium', 'BINARIES_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium Binaries', 'CHROME_DIR': 'Chromium', 'CHROME_HTML_PROG_ID': 'ChromiumHTM', 'CHROME_LONG_NAME': 'Chromium', 'CHROME_SHORT_NAME': 'Chromium', 'CHROME_UPDATE_REGISTRY_SUBKEY': 'Software\\Chromium', 'CHROME_CLIENT_STATE_KEY': 'Software\\Chromium', }) else: raise KeyError("Unknown mini_installer product name '%s'" % mini_installer_product_name)
def __init__(self, mini_installer_path): """Constructor. The constructor initializes a variable dictionary that maps variables to their values. These are the only acceptable variables: * $PROGRAM_FILE: the unquoted path to the Program Files folder. * $LOCAL_APPDATA: the unquoted path to the Local Application Data folder. * $MINI_INSTALLER: the unquoted path to the mini_installer. * $MINI_INSTALLER_FILE_VERSION: the file version of the mini_installer. * $CHROME_SHORT_NAME: 'Chrome' (or 'Chromium'). * $CHROME_LONG_NAME: 'Google Chrome' (or 'Chromium'). * $CHROME_DIR: the directory of Chrome (or Chromium) from the base installation directory. * $CHROME_UPDATE_REGISTRY_SUBKEY: the registry key, excluding the root key, of Chrome for Google Update. * $CHROME_HTML_PROG_ID: 'ChromeHTML' (or 'ChromiumHTM'). * $USER_SPECIFIC_REGISTRY_SUFFIX: the output from the function _GetUserSpecificRegistrySuffix(). * $WINDOWS_VERSION: a 2-tuple representing the current Windows version. * $VERSION_[XP/SERVER_2003/VISTA/WIN7/WIN8/WIN8_1]: a 2-tuple representing the version of the corresponding OS. Args: mini_installer_path: The path to mini_installer.exe. """ mini_installer_abspath = os.path.abspath(mini_installer_path) mini_installer_file_version = _GetFileVersion(mini_installer_abspath) mini_installer_product_name = _GetProductName(mini_installer_abspath) program_files_path = shell.SHGetFolderPath(0, shellcon.CSIDL_PROGRAM_FILES, None, 0) local_appdata_path = shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, None, 0) user_specific_registry_suffix = _GetUserSpecificRegistrySuffix() windows_major_ver, windows_minor_ver, _, _, _ = win32api.GetVersionEx() # This string will be converted to a tuple once injected in eval() through # conditional checks. Tuples are compared lexicographically. windows_version = '(%s, %s)' % (windows_major_ver, windows_minor_ver) if mini_installer_product_name == 'Google Chrome Installer': chrome_short_name = 'Chrome' chrome_long_name = 'Google Chrome' chrome_dir = 'Google\\Chrome' chrome_update_registry_subkey = ('Software\\Google\\Update\\Clients\\' '{8A69D345-D564-463c-AFF1-A69D9E530F96}') chrome_html_prog_id = 'ChromeHTML' elif mini_installer_product_name == 'Chromium Installer': chrome_short_name = 'Chromium' chrome_long_name = 'Chromium' chrome_dir = 'Chromium' chrome_update_registry_subkey = 'Software\\Chromium' chrome_html_prog_id = 'ChromiumHTM' else: raise KeyError("Unknown mini_installer product name '%s'" % mini_installer_product_name) self._variable_mapping = { 'PROGRAM_FILES': program_files_path, 'LOCAL_APPDATA': local_appdata_path, 'MINI_INSTALLER': mini_installer_abspath, 'MINI_INSTALLER_FILE_VERSION': mini_installer_file_version, 'CHROME_SHORT_NAME': chrome_short_name, 'CHROME_LONG_NAME': chrome_long_name, 'CHROME_DIR': chrome_dir, 'CHROME_UPDATE_REGISTRY_SUBKEY': chrome_update_registry_subkey, 'CHROME_HTML_PROG_ID': chrome_html_prog_id, 'USER_SPECIFIC_REGISTRY_SUFFIX': user_specific_registry_suffix, 'WINDOWS_VERSION': windows_version, 'VERSION_XP': '(5, 1)', 'VERSION_SERVER_2003': '(5, 2)', 'VERSION_VISTA': '(6, 0)', 'VERSION_WIN7': '(6, 1)', 'VERSION_WIN8': '(6, 2)', 'VERSION_WIN8_1': '(6, 3)', }
def host_is_dc(): return win32api.GetVersionEx(1)[8] == 2