Python sys 模块,getwindowsversion() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sys.getwindowsversion()

项目:code    作者:ActiveState    | 项目源码 | 文件源码
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)
项目:Qyoutube-dl    作者:lzambella    | 项目源码 | 文件源码
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

    return s.encode(get_subprocess_encoding(), 'ignore')
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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)
项目:youtube_downloader    作者:aksinghdce    | 项目源码 | 文件源码
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')
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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)
项目:optimalvibes    作者:littlemika    | 项目源码 | 文件源码
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')
项目:tvalacarta    作者:tvalacarta    | 项目源码 | 文件源码
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')
项目:respeaker_virtualenv    作者:respeaker    | 项目源码 | 文件源码
def get_winver():
        wv = sys.getwindowsversion()
        if hasattr(wv, 'service_pack_major'):  # python >= 2.7
            sp = wv.service_pack_major or 0
        else:
            r = re.search("\s\d$", wv[4])
            if r:
                sp = int(r.group(0))
            else:
                sp = 0
        return (wv[0], wv[1], sp)


# ===================================================================
# --- sync primitives
# ===================================================================
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
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
项目:kodi-plugin.video.ted-talks-chinese    作者:daineseh    | 项目源码 | 文件源码
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')
项目:GUIYoutube    作者:coltking    | 项目源码 | 文件源码
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')
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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 as 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)
项目:Yv-dl    作者:r0oth3x49    | 项目源码 | 文件源码
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')
项目:anime-dl    作者:Xonshiz    | 项目源码 | 文件源码
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')
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def get_winver():
        wv = sys.getwindowsversion()
        if hasattr(wv, 'service_pack_major'):  # python >= 2.7
            sp = wv.service_pack_major or 0
        else:
            r = re.search("\s\d$", wv[4])
            if r:
                sp = int(r.group(0))
            else:
                sp = 0
        return (wv[0], wv[1], sp)


# ===================================================================
# --- sync primitives
# ===================================================================
项目:get-youtube-subtitle-url-node    作者:joegesualdo    | 项目源码 | 文件源码
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')
项目:FancyWord    作者:EastonLee    | 项目源码 | 文件源码
def get_winver():
        wv = sys.getwindowsversion()
        if hasattr(wv, 'service_pack_major'):  # python >= 2.7
            sp = wv.service_pack_major or 0
        else:
            r = re.search("\s\d$", wv[4])
            if r:
                sp = int(r.group(0))
            else:
                sp = 0
        return (wv[0], wv[1], sp)


# ===================================================================
# --- sync primitives
# ===================================================================
项目:ngDownloaderAPI    作者:manishbisht    | 项目源码 | 文件源码
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')
项目:mac-package-build    作者:persepolisdm    | 项目源码 | 文件源码
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
项目:NoWannaNoCry    作者:dolang    | 项目源码 | 文件源码
def os_id_index():
    """Get the index of the machine OS in the `OS_ID` tuple.

    The `OS_ID` tuple contains the major and minor version of all
    affected Windows versions.  These are matched against
    the major and minor version of `sys.getwindowsversion()`.

    For Windows 8.1 and above `sys.getwindowsversion()` doesn't
    report the correct value, these systems are handled specially. 

    Windows 8 and Server 2012 are special cased because the have the
    same version numbers but require different KBs.

    :return: The index of the operating system in `OS_ID`.
    :rtype: int
    """
    winver = sys.getwindowsversion()
    # sys.getwindowsversion is not enough by itself as the underlying
    # API has been deprecated.  Only applications which have been
    # developed specifically for Windows 8.1 and above, and write that
    # into their manifest file get the correct Windows version on those
    # systems.  Other applications (Python doesn't have the manifest)
    # get a version that pretends to be Windows 8 (major=6, minor=2).
    # See:
    # https://msdn.microsoft.com/en-us/library/windows/desktop/ms724834.aspx
    major, minor = winver.major, winver.minor
    if (major, minor) == (6, 2):
        # Determine if this system is a newer version than Windows 8 by
        # parsing the version string in `platform.win32_ver()[1]`:
        major, minor = tuple(map(int, platform.win32_ver()[1].split('.')[:2]))
    for i, os_id in enumerate(OS_ID):
        if os_id[:2] == (major, minor):
            if len(os_id) == 2:
                return i
            # else evaluate the third item if present which is a lambda:
            if os_id[2]():
                return i
            # otherwise continue with the next item
项目:petronia    作者:groboclown    | 项目源码 | 文件源码
def __load_functions(modules):
    import platform
    import struct

    # Ensure we're on Windows
    assert 'windows' in platform.system().lower()
    void_ptr_bits = struct.calcsize('P') * 8
    winver = sys.getwindowsversion()
    environ = {
        '32-bit': void_ptr_bits == 32,
        '64-bit': void_ptr_bits == 64,
        'release': platform.release(),
        'version': platform.version(),
        'system': platform.system(),
        'version-major': winver.major,
        'version-minor': winver.minor,
        'version-build': winver.build,
        'version-platform': winver.platform,
        'version-service_pack': winver.service_pack,
    }

    ret = {}
    for name in modules:
        if isinstance(name, str):
            try:
                mod = importlib.import_module(name, __name__)
            except:
                print("Problem loading module " + name)
                raise
        else:
            mod = name
        mod.load_functions(environ, ret)
    return ret
项目:pymotw3    作者:reingart    | 项目源码 | 文件源码
def __init__(self):
    self._user      = None                  # User-specified default encoding
    self._learned   = []                    # Learned default encodings
    self._widefiles = False                 # File system can be wide

    # Can the file system be Unicode?
    try:
      self._widefiles = os.path.supports_unicode_filenames
    except AttributeError:
      try:
        self._widefiles = sys.getwindowsversion() == os.VER_PLATFORM_WIN32_NT
      except AttributeError:
        pass

    # Try to guess a working default
    try:
      encoding = sys.getfilesystemencoding()
      if encoding and not (encoding.upper() in ENC_ASCII_LIST):
        self._learned = [ encoding ]
    except AttributeError:
      pass

    if not self._learned:
      encoding = sys.getdefaultencoding()
      if encoding and not (encoding.upper() in ENC_ASCII_LIST):
        self._learned = [ encoding ]

    # If we had no guesses, start with some European defaults
    if not self._learned:
      self._learned = ENC_DEFAULT_LIST
  #end def __init__
项目:Qyoutube-dl    作者:lzambella    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
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."
项目:EMFT    作者:132nd-etcher    | 项目源码 | 文件源码
def set_context(self):
        self.tags_context(
            dict(
                frozen=constant.FROZEN,
                platform=sys.platform,
                release_name=constant.APP_RELEASE_NAME,
            )
        )
        try:
            self.tags_context(dict(windows_version=sys.getwindowsversion()))
        except AttributeError:
            pass
项目:youtube_downloader    作者:aksinghdce    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:optimalvibes    作者:littlemika    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:nc-backup-py    作者:ChinaNetCloud    | 项目源码 | 文件源码
def isWindows():
        if getattr(sys, "getwindowsversion", None) is not None:
            return sys.getwindowsversion()[0] == 6
        else:
            return False
项目:tvalacarta    作者:tvalacarta    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def send_bugreport(self):
        """
        Return None if successful. Return the urllib2 execption if failure.
        """
        try:
            windowsversion = str(sys.getwindowsversion())
        except AttributeError:
            windowsversion = "(not running ms windows)"
        buf = self.g_tw.get_buffer()
        description = buf.get_text(buf.get_start_iter(), buf.get_end_iter(),
                                   False)
        data = urllib.urlencode({
            'email': self.g_email.get_text(),
            'version': buildinfo.VERSION_STRING,
            'revision_id': buildinfo.REVISION_ID,
            #'pygtk_version': "pygi",
            'gtk': "(%s.%s.%s)" % (Gtk.get_major_version(),
                                         Gtk.get_minor_version(),
                                         Gtk.get_micro_version()),
            'sys.version': sys.version,
            'sys.platform': sys.platform,
            'windowsversion': windowsversion,
            'short_description': self.g_description.get_text(),
            'description': description,
            'traceback': self.m_error_text,
        })
        try:
            urllib2.urlopen("http://www.solfege.org/crashreport/", data)
        except urllib2.HTTPError, e:
            print "HTTPError:", e
        return
项目:echo-icloud    作者:Blakewell    | 项目源码 | 文件源码
def is_win32_crypto_supported():
    try:
        __import__('keyring.backends._win_crypto')
    except ImportError:
        return False
    return sys.platform in ['win32'] and sys.getwindowsversion()[-2] == 2
项目:echo-icloud    作者:Blakewell    | 项目源码 | 文件源码
def is_winvault_supported():
    try:
        __import__('win32cred')
        has_pywin32 = True
    except ImportError:
        has_pywin32 = False
    return (
        sys.platform in ['win32'] and sys.getwindowsversion().major >= 6
        and has_pywin32
    )
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def get_policy_dir(cls):
        winsxs = os.path.join(compat.getenv("SystemRoot"), "WinSxS")
        if sys.getwindowsversion() < (6, ):
            # Windows XP
            pcfiles = os.path.join(winsxs, "Policies")
            if not os.path.isdir(pcfiles):
                logger.warn("No such dir %s", pcfiles)
        else:
            # Vista or later
            pcfiles = cls.get_manifest_dir()
        return pcfiles
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.test_support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.test_support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()
项目:kodi-plugin.video.ted-talks-chinese    作者:daineseh    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:GUIYoutube    作者:coltking    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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."
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def test_bad_mem(self):
        self.failUnlessRaises(pywintypes.error, GetGlobalMemory, 0)
        self.failUnlessRaises(pywintypes.error, GetGlobalMemory, -1)
        if sys.getwindowsversion()[0] <= 5:
            # For some reason, the value '1' dies from a 64bit process, but
            # "works" (ie, gives the correct exception) from a 32bit process.
            # just silently skip this value on Vista.
            self.failUnlessRaises(pywintypes.error, GetGlobalMemory, 1)
项目:wintenApps    作者:josephsl    | 项目源码 | 文件源码
def onInstall():
    requiredVer = "Windows 10 Version 1703"
    # Translators: Dialog text shown when attempting to install the add-on on an unsupported version of Windows (minSupportedVersion is the minimum version required for this add-on).
    if sys.getwindowsversion().build < 15063 and gui.messageBox(_("You are using an older version of Windows. This add-on requires {minSupportedVersion} or later. Are you sure you wish to install this add-on anyway?").format(minSupportedVersion = requiredVer),
    # Translators: title of the dialog shown when attempting to install the add-on on an old version of Windows.
    _("Old Windows version"), wx.YES | wx.NO | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.NO:
        raise RuntimeError("Old Windows version detected")
项目:wintenApps    作者:josephsl    | 项目源码 | 文件源码
def event_NVDAObject_init(self, obj):
        if isinstance(obj, UIA):
            # Despite repeated feedback, there's at least one unlabeled toggle button in Settings app.
            # One particular case is Settings/Update/Developer Mode with USB/LAN discovery toggle button in Redstone (fixed in build 14986).
            # Another case is with various combo boxes in Redstone 2 with no labels.
            # Yet another case is Devices/Bluetooth lists.
            if obj.name == "" and (obj.role in (controlTypes.ROLE_TOGGLEBUTTON, controlTypes.ROLE_COMBOBOX) and obj.UIAElement.cachedAutomationID
                or obj.role == controlTypes.ROLE_LIST and obj.UIAElement.cachedAutomationID in ("SystemSettings_Devices_AudioDeviceList_ListView", "SystemSettings_Devices_OtherDeviceList_ListView")):
                # But some combo boxes, such as Insider level combo box in Creators Update has the following problem.
                try:
                    obj.name = obj.previous.name
                except AttributeError:
                    obj.name = obj.parent.previous.name
            # Recognize groups of controls for contextual output (more prominent in Redstone 2).
            elif obj.UIAElement.cachedAutomationID.endswith("GroupTitleTextBlock"):
                obj.role = controlTypes.ROLE_GROUPING
            # From Redstone 1 onwards, update history shows status rather than the title.
            # In build 16232, the title is shown but not the status, so include this for sake of backward compatibility.
            elif obj.role == controlTypes.ROLE_LINK and obj.UIAElement.cachedAutomationID.startswith("HistoryEvent") and obj.name != obj.previous.name:
                nameList = [obj.name]
                build = sys.getwindowsversion().build
                # For 1703.
                if build == 15063:
                    nameList.insert(0, obj.previous.name)
                # Add the status text in 1709 and later.
                # But since 16251, a "what's new" link has been added for feature updates, so consult two previous objects.
                elif build >= 16299:
                    automationID = obj.UIAElement.cachedAutomationID
                    eventID = automationID.split("_")[0]
                    possibleFeatureUpdateText = obj.previous.previous
                    # This automation ID may change in a future Windows 10 release.
                    if possibleFeatureUpdateText.UIAElement.cachedAutomationID == "_".join([eventID, "TitleTextBlock"]):
                        nameList.insert(0, obj.previous.name)
                        nameList.insert(0, possibleFeatureUpdateText.name)
                    else:
                        nameList.append(obj.next.name)
                obj.name = ", ".join(nameList)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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.")
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def test_bad_mem(self):
        self.failUnlessRaises(pywintypes.error, GetGlobalMemory, 0)
        self.failUnlessRaises(pywintypes.error, GetGlobalMemory, -1)
        if sys.getwindowsversion()[0] <= 5:
            # For some reason, the value '1' dies from a 64bit process, but
            # "works" (ie, gives the correct exception) from a 32bit process.
            # just silently skip this value on Vista.
            self.failUnlessRaises(pywintypes.error, GetGlobalMemory, 1)
项目:Yv-dl    作者:r0oth3x49    | 项目源码 | 文件源码
def get_subprocess_encoding():
    if sys.platform == 'win32' and sys.getwindowsversion()[0] >= 5:
        # For subprocess calls, encode with locale encoding
        # Refer to http://stackoverflow.com/a/9951851/35070
        encoding = preferredencoding()
    else:
        encoding = sys.getfilesystemencoding()
    if encoding is None:
        encoding = 'utf-8'
    return encoding
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.test_support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_getwindowsversion(self):
        # Raise SkipTest if sys doesn't have getwindowsversion attribute
        test.support.get_attribute(sys, "getwindowsversion")
        v = sys.getwindowsversion()
        self.assertEqual(len(v), 5)
        self.assertIsInstance(v[0], int)
        self.assertIsInstance(v[1], int)
        self.assertIsInstance(v[2], int)
        self.assertIsInstance(v[3], int)
        self.assertIsInstance(v[4], str)
        self.assertRaises(IndexError, operator.getitem, v, 5)
        self.assertIsInstance(v.major, int)
        self.assertIsInstance(v.minor, int)
        self.assertIsInstance(v.build, int)
        self.assertIsInstance(v.platform, int)
        self.assertIsInstance(v.service_pack, str)
        self.assertIsInstance(v.service_pack_minor, int)
        self.assertIsInstance(v.service_pack_major, int)
        self.assertIsInstance(v.suite_mask, int)
        self.assertIsInstance(v.product_type, int)
        self.assertEqual(v[0], v.major)
        self.assertEqual(v[1], v.minor)
        self.assertEqual(v[2], v.build)
        self.assertEqual(v[3], v.platform)
        self.assertEqual(v[4], v.service_pack)

        # This is how platform.py calls it. Make sure tuple
        #  still has 5 elements
        maj, min, buildno, plat, csd = sys.getwindowsversion()
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def assert_raise_on_new_sys_type(self, sys_attr):
        # Users are intentionally prevented from creating new instances of
        # sys.flags, sys.version_info, and sys.getwindowsversion.
        attr_type = type(sys_attr)
        with self.assertRaises(TypeError):
            attr_type()
        with self.assertRaises(TypeError):
            attr_type.__new__(attr_type)