python类getwindowsversion()的实例源码

test_sys.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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()
reportbug.py 文件源码 项目:Solfege 作者: RannyeriDev 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
test_Windows.py 文件源码 项目:echo-icloud 作者: Blakewell 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
test_Windows.py 文件源码 项目:echo-icloud 作者: Blakewell 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
    )
winmanifest.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
test_sys.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
test_sys.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
utils.py 文件源码 项目:kodi-plugin.video.ted-talks-chinese 作者: daineseh 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
utils.py 文件源码 项目:GUIYoutube 作者: coltking 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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
test_sys.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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()
folder_view.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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."
test_clipboard.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
installTasks.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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")
systemsettings.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
folder_view.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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.")
test_clipboard.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
utils.py 文件源码 项目:Yv-dl 作者: r0oth3x49 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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
test_sys.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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()
test_sys.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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()
test_sys.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号