当前位置: 首页>>代码示例>>Python>>正文


Python sys.getwindowsversion方法代码示例

本文整理汇总了Python中sys.getwindowsversion方法的典型用法代码示例。如果您正苦于以下问题:Python sys.getwindowsversion方法的具体用法?Python sys.getwindowsversion怎么用?Python sys.getwindowsversion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


在下文中一共展示了sys.getwindowsversion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resolveMUITimeZone

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def resolveMUITimeZone(spec):
	"""Resolve a multilingual user interface resource for the time zone name
	>>> #some pre-amble for the doc-tests to be py2k and py3k aware)
	>>> try: unicode and None
	... except NameError: unicode=str
	...
	>>> result = resolveMUITimeZone('@tzres.dll,-110')
	>>> expectedResultType = [type(None),unicode][sys.getwindowsversion() >= (6,)]
	>>> type(result) is expectedResultType
	True
	
	spec should be of the format @path,-stringID[;comment]
	see http://msdn2.microsoft.com/en-us/library/ms725481.aspx for details
	"""
	pattern = re.compile('@(?P<dllname>.*),-(?P<index>\d+)(?:;(?P<comment>.*))?')
	matcher = pattern.match(spec)
	assert matcher, 'Could not parse MUI spec'

	try:
		handle = DLLCache[matcher.groupdict()['dllname']]
		result = win32api.LoadString(handle, int(matcher.groupdict()['index']))
	except win32api.error, e:
		result = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:win32timezone.py

示例2: UseCommandLine

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def UseCommandLine(*classes, **flags):
  unregisterInfo = '--unregister_info' in sys.argv
  unregister = '--unregister' in sys.argv
  flags['quiet'] = flags.get('quiet',0) or '--quiet' in sys.argv
  flags['debug'] = flags.get('debug',0) or '--debug' in sys.argv
  flags['unattended'] = flags.get('unattended',0) or '--unattended' in sys.argv
  if unregisterInfo:
    return UnregisterInfoClasses(*classes, **flags)
  try:
    if unregister:
      UnregisterClasses(*classes, **flags)
    else:
      RegisterClasses(*classes, **flags)
  except win32api.error, exc:
    # If we are on xp+ and have "access denied", retry using
    # ShellExecuteEx with 'runas' verb to force elevation (vista) and/or
    # admin login dialog (vista/xp)
    if flags['unattended'] or exc.winerror != winerror.ERROR_ACCESS_DENIED \
       or sys.getwindowsversion()[0] < 5:
      raise
    ReExecuteElevated(flags) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:register.py

示例3: get_winver

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def get_winver():
    if not WINDOWS:
        raise NotImplementedError("not WINDOWS")
    wv = sys.getwindowsversion()
    if hasattr(wv, 'service_pack_major'):  # python >= 2.7
        sp = wv.service_pack_major or 0
    else:
        r = re.search(r"\s\d$", wv[4])
        if r:
            sp = int(r.group(0))
        else:
            sp = 0
    return (wv[0], wv[1], sp)


# ===================================================================
# --- sync primitives
# =================================================================== 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:20,代码来源:__init__.py

示例4: test_cpu_count

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def test_cpu_count(self):
        logical = psutil.cpu_count()
        self.assertEqual(logical, len(psutil.cpu_times(percpu=True)))
        self.assertGreaterEqual(logical, 1)
        #
        if os.path.exists("/proc/cpuinfo"):
            with open("/proc/cpuinfo") as fd:
                cpuinfo_data = fd.read()
            if "physical id" not in cpuinfo_data:
                raise unittest.SkipTest("cpuinfo doesn't include physical id")
        physical = psutil.cpu_count(logical=False)
        if WINDOWS and sys.getwindowsversion()[:2] <= (6, 1):  # <= Vista
            self.assertIsNone(physical)
        else:
            self.assertGreaterEqual(physical, 1)
            self.assertGreaterEqual(logical, physical) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:test_system.py

示例5: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def __init__(self):
        super(WindowsDefaults, self)
        from .win_app_paths import get_non_syspath_dirs
        self._tweaked_syspath = get_non_syspath_dirs() + os.environ["PATH"].split(os.path.pathsep)

        # Windows 10 supports colored output since anniversary update (build 14393)
        # so we try to use it (it has to be enabled since it is always disabled by default!)
        try:
            wininfo = sys.getwindowsversion()
            if wininfo.major >= 10 and wininfo.build >= 14393:

                import ctypes as ct
                h_kernel32 = ct.windll.kernel32

                #  STD_OUTPUT_HANDLE = -11
                # -> https://docs.microsoft.com/en-us/windows/console/getstdhandle
                h_stdout = h_kernel32.GetStdHandle(-11)

                # ENABLE_PROCESSED_OUTPUT  | ENABLE_WRAP_AT_EOL_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING = 7
                # -> https://docs.microsoft.com/en-us/windows/console/setconsolemode
                result = h_kernel32.SetConsoleMode(h_stdout, 7)

                self.console_colors = "always"
        except (ImportError, AttributeError):
            pass 
开发者ID:textext,项目名称:textext,代码行数:27,代码来源:requirements_check.py

示例6: encodeFilename

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def encodeFilename(s, for_subprocess=False):
    """
    @param s The name of the file
    """

    assert type(s) == compat_str

    # Python 3 has a Unicode API
    if sys.version_info >= (3, 0):
        return s

    # Pass '' directly to use Unicode APIs on Windows 2000 and up
    # (Detecting Windows NT 4 is tricky because 'major >= 4' would
    # match Windows 9x series as well. Besides, NT 4 is obsolete.)
    if not for_subprocess and sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        return s

    # Jython assumes filenames are Unicode strings though reported as Python 2.x compatible
    if sys.platform.startswith('java'):
        return s

    return s.encode(get_subprocess_encoding(), 'ignore') 
开发者ID:tvalacarta,项目名称:tvalacarta,代码行数:24,代码来源:utils.py

示例7: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def __init__(self, gtk_window):

        self._window = gtk_window
        self._hwnd = gtk_window.window.handle

        self._message_map = {}

        # Windows transparency is only supported windows2000 and above.
        if sys.getwindowsversion()[0] <= 4:
            self.alpha = None
        else:
            self.alpha = 100
            self._transparency = False

        self.notify_icon = None            

        # Sublass the window and inject a WNDPROC to process messages.
        self._oldwndproc = win32gui.SetWindowLong(self._hwnd, GWL_WNDPROC,
                                                  self._wndproc)

        gtk_window.connect('unrealize', self.remove) 
开发者ID:ActiveState,项目名称:code,代码行数:23,代码来源:recipe-334779.py

示例8: _mss_bugfix

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def _mss_bugfix(self):
        """Temporary windows DPI bugfix for mss"""

        os_ = platform.system().lower()
        if os_ == "windows":
            version = sys.getwindowsversion()[:2]
            if version >= (6, 3):
                # Windows 8.1+
                # Here 2 = PROCESS_PER_MONITOR_DPI_AWARE, which means:
                #     per monitor DPI aware. This app checks for the DPI when it is
                #     created and adjusts the scale factor whenever the DPI changes.
                #     These applications are not automatically scaled by the system.
                ctypes.windll.shcore.SetProcessDpiAwareness(2)
            elif (6, 0) <= version < (6, 3):
                # Windows Vista, 7, 8 and Server 2012
                ctypes.windll.user32.SetProcessDPIAware() 
开发者ID:SergeyKalutsky,项目名称:vsc,代码行数:18,代码来源:classifier.py

示例9: getlanguage

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def getlanguage(self, language=None, windowsversion=None):
        """
        Get and return the manifest's language as string.
        
        Can be either language-culture e.g. 'en-us' or a string indicating 
        language neutrality, e.g. 'x-ww' on Windows XP or 'none' on Vista 
        and later.
        
        """
        if not language:
            language = self.language
        if language in (None, "", "*", "neutral"):
            return (LANGUAGE_NEUTRAL_NT5,
                    LANGUAGE_NEUTRAL_NT6)[(windowsversion or 
                                           sys.getwindowsversion()) >= (6, )]
        return language 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:18,代码来源:winmanifest.py

示例10: _win_version_pair

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def _win_version_pair():
    ver_info = sys.getwindowsversion()
    return (ver_info[0], ver_info[1]) 
开发者ID:wbond,项目名称:oscrypto,代码行数:5,代码来源:test_asymmetric.py

示例11: backend

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def backend():
    """
    :return:
        A unicode string of the backend being used: "openssl", "mac", "win",
        "winlegacy"
    """

    if _module_values['backend'] is not None:
        return _module_values['backend']

    with _backend_lock:
        if _module_values['backend'] is not None:
            return _module_values['backend']

        if sys.platform == 'win32':
            # Windows XP was major version 5, Vista was 6
            if sys.getwindowsversion()[0] < 6:
                _module_values['backend'] = 'winlegacy'
            else:
                _module_values['backend'] = 'win'
        elif sys.platform == 'darwin':
            _module_values['backend'] = 'mac'
        else:
            _module_values['backend'] = 'openssl'

        return _module_values['backend'] 
开发者ID:wbond,项目名称:oscrypto,代码行数:28,代码来源:__init__.py

示例12: get_platform

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def get_platform():
    platforms = {
        "Linux": "X11; Linux",
        "Windows": "Windows NT %d.%d",
        "OSX": "Macintosh; Intel Mac OS X",
        "IOS": "iPad; CPU OS 6_1 like Mac OS X",
    }
    for platform, ua_platform_name in platforms.items():
        if xbmc.getCondVisibility("System.Platform.%s" % platform):
            if platform == "Windows":
                import sys
                version = sys.getwindowsversion()
                ua_platform_name %= (version[0], version[1])
            return ua_platform_name 
开发者ID:jmarth,项目名称:plugin.video.kmediatorrent,代码行数:16,代码来源:ga.py

示例13: _wrap_std_stream

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def _wrap_std_stream(name):
    # Python 2 & Windows 7 and below
    if PY2 and sys.getwindowsversion()[:2] <= (6, 1) and name not in _wrapped_std_streams:
        setattr(sys, name, WindowsChunkedWriter(getattr(sys, name)))
        _wrapped_std_streams.add(name) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:_winconsole.py

示例14: launch_ST2

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def launch_ST2(self, files):
        items = ["-n"] + files
        cwd = None if NT else self.path
        shell = False
        if NT:
            # 9200 means win8
            shell = True if sys.getwindowsversion()[2] < 9200 else False
            items = [i.encode(locale.getpreferredencoding(False)) if sys.getwindowsversion()[2] == 9200 else i for i in items]

        def app_path():
            if OSX:
                app_path = subprocess.Popen(["osascript", "-e" "tell application \"System Events\" to POSIX path of (file of process \"Sublime Text 2\" as alias)"], stdout=subprocess.PIPE).communicate()[0].rstrip()
                subl_path = "{0}/Contents/SharedSupport/bin/subl".format(app_path)
            else:
                subl_path = 'sublime_text'
            yield subl_path

        fail = False
        for c in ['subl', 'sublime', app_path()]:
            try:
                subprocess.Popen(list(c) + items, cwd=cwd, shell=shell)
            except:
                fail = True
            else:
                fail = False

        if fail:
            sublime.status_message('Cannot open a new window') 
开发者ID:aziz,项目名称:SublimeFileBrowser,代码行数:30,代码来源:dired_misc.py

示例15: DllRegisterServer

# 需要导入模块: import sys [as 别名]
# 或者: from sys import getwindowsversion [as 别名]
def DllRegisterServer():
    import _winreg
    if sys.getwindowsversion()[0] < 6:
        print "This sample only works on Vista"
        sys.exit(1)

    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolder._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    # register the context menu handler under the FolderViewSampleType type.
    keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_)
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_)
    propsys.PSRegisterPropertySchema(get_schema_fname())
    print ShellFolder._reg_desc_, "registration complete." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:28,代码来源:folder_view.py


注:本文中的sys.getwindowsversion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。