當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。