def __init__(self):
if self.info is not None:
return
info = []
try:
#XXX: Bad style to use so long `try:...except:...`. Fix it!
import _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 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( str(sys.exc_info()) + '(ignoring)' )
self.__class__.info = info
评论列表
文章目录