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


Python _winreg.error方法代码示例

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


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

示例1: _doregister

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def _doregister(mod_name, dll_name):
    assert os.path.isfile(dll_name), "Shouldn't get here if the file doesn't exist!"
    try:
        key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
    except _winreg.error:
        try:
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
        except _winreg.error:
            print "Could not find the existing '%s' module registered in the registry" % (mod_name,)
            usage_and_die(4)
    # Create the debug key.
    sub_key = _winreg.CreateKey(key, "Debug")
    _winreg.SetValue(sub_key, None, _winreg.REG_SZ, dll_name)
    print "Registered '%s' in the registry" % (dll_name,) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:setup_d.py

示例2: test_struct_uint_bad_value_cp20039

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def test_struct_uint_bad_value_cp20039(self):
        class x(object):
            def __init__(self, value):
                self.value = value
            def __and__(self, other):
                global andCalled
                andCalled = True
                return self.value
            def __int__(self):
                raise Exception('foo')

        import _struct
        global andCalled
        andCalled = False

        self.assertRaisesRegexp(_struct.error, "integer out of range for 'L' format code",
                            _struct.Struct('L').pack, 4294967296)
        self.assertRaisesRegexp(_struct.error, "integer out of range for 'L' format code",
                            _struct.Struct('L').pack, -1)
        self.assertRaisesRegexp(Exception, "foo",
                            _struct.Struct('L').pack, x(0))
        self.assertRaisesRegexp(Exception, "foo", _struct.Struct('L').pack, x(-1))

        self.assertRaisesRegexp(_struct.error, "integer out of range for 'I' format code",
                            _struct.Struct('I').pack, 4294967296)
        self.assertRaisesRegexp(_struct.error, "integer out of range for 'I' format code",
                            _struct.Struct('I').pack, -1)
        self.assertRaisesRegexp(Exception, "foo",
                            _struct.Struct('I').pack, x(0))
        self.assertRaisesRegexp(Exception, "foo", _struct.Struct('I').pack, x(-1))

        # __and__ was called in Python2.6 check that this is no longer True
        self.assertTrue(not andCalled) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:35,代码来源:test_regressions.py

示例3: test_winreg_error_cp17050

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def test_winreg_error_cp17050(self):
        import _winreg
        self.assertEqual(_winreg.error, WindowsError) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_regressions.py

示例4: __call__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def __call__(self, env, source, ext=None):
        if ext is None:
            try:
                ext = source[0].suffix
            except IndexError:
                ext = ""
        try:
            return self[ext]
        except KeyError:
            # Try to perform Environment substitution on the keys of
            # the dictionary before giving up.
            s_dict = {}
            for (k,v) in self.items():
                if k is not None:
                    s_k = env.subst(k)
                    if s_k in s_dict:
                        # We only raise an error when variables point
                        # to the same suffix.  If one suffix is literal
                        # and a variable suffix contains this literal,
                        # the literal wins and we don't raise an error.
                        raise KeyError(s_dict[s_k][0], k, s_k)
                    s_dict[s_k] = (k,v)
            try:
                return s_dict[ext][1]
            except KeyError:
                try:
                    return self[None]
                except KeyError:
                    return None 
开发者ID:coin3d,项目名称:pivy,代码行数:31,代码来源:Util.py

示例5: __init__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                try:
                    proc=winreg.EnumKey(chnd, pnum)
                except winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=winreg.OpenKey(chnd, proc)
                    pidx=0
                    while True:
                        try:
                            name, value, vtpe=winreg.EnumValue(phnd, pidx)
                        except winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except Exception:
            print(sys.exc_info()[1], '(ignoring)')
        self.__class__.info = info 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:44,代码来源:cpuinfo.py

示例6: __init__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              r"\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                try:
                    proc=winreg.EnumKey(chnd, pnum)
                except winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=winreg.OpenKey(chnd, proc)
                    pidx=0
                    while True:
                        try:
                            name, value, vtpe=winreg.EnumValue(phnd, pidx)
                        except winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except:
            print(sys.exc_info()[1], '(ignoring)')
        self.__class__.info = info 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:44,代码来源:cpuinfo.py

示例7: __init__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def __init__(self):
        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!
            if sys.version_info[0] >= 3:
                import winreg
            else:
                import _winreg as winreg

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"\
                              "\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd=winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum=0
            while True:
                try:
                    proc=winreg.EnumKey(chnd, pnum)
                except winreg.error:
                    break
                else:
                    pnum+=1
                    info.append({"Processor":proc})
                    phnd=winreg.OpenKey(chnd, proc)
                    pidx=0
                    while True:
                        try:
                            name, value, vtpe=winreg.EnumValue(phnd, pidx)
                        except winreg.error:
                            break
                        else:
                            pidx=pidx+1
                            info[-1][name]=value
                            if name=="Identifier":
                                srch=prgx.search(value)
                                if srch:
                                    info[-1]["Family"]=int(srch.group("FML"))
                                    info[-1]["Model"]=int(srch.group("MDL"))
                                    info[-1]["Stepping"]=int(srch.group("STP"))
        except:
            print(sys.exc_info()[1], '(ignoring)')
        self.__class__.info = info 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:44,代码来源:cpuinfo.py

示例8: __init__

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import error [as 别名]
def __init__(self):
        try:
            import _winreg
        except ImportError:  # Python 3
            import winreg as _winreg

        if self.info is not None:
            return
        info = []
        try:
            #XXX: Bad style to use so long `try:...except:...`. Fix it!

            prgx = re.compile(r"family\s+(?P<FML>\d+)\s+model\s+(?P<MDL>\d+)"
                              "\s+stepping\s+(?P<STP>\d+)", re.IGNORECASE)
            chnd = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, self.pkey)
            pnum = 0
            while 1:
                try:
                    proc = _winreg.EnumKey(chnd, pnum)
                except _winreg.error:
                    break
                else:
                    pnum += 1
                    info.append({"Processor": proc})
                    phnd = _winreg.OpenKey(chnd, proc)
                    pidx = 0
                    while True:
                        try:
                            name, value, vtpe = _winreg.EnumValue(phnd, pidx)
                        except _winreg.error:
                            break
                        else:
                            pidx = pidx + 1
                            info[-1][name] = value
                            if name == "Identifier":
                                srch = prgx.search(value)
                                if srch:
                                    info[-1]["Family"] = int(srch.group("FML"))
                                    info[-1]["Model"] = int(srch.group("MDL"))
                                    info[-1]["Stepping"] = int(srch.group("STP"))
        except:
            print(sys.exc_value, '(ignoring)')
        self.__class__.info = info 
开发者ID:cics-nd,项目名称:ar-pde-cnn,代码行数:45,代码来源:cpuinfo.py


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