def _registryKey(db):
registry = Registry()
path = "HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBC.INI\\%ssql" % db
pathList = path.split("\\")
key = registry.getSubKey(pathList[0] )
for keyName in pathList[1:]:
key = key.getSubKey(keyName)
return key
def get_hostname(config="optimus"):
try:
odbcRegistryKey = _registryKey(config)
except Exception, e:
hostname = getHostName()
else:
hostname = odbcRegistryKey["Server"]
return hostname
DBNAME = getOptimusSession().dbname
HOSTNAME = get_hostname(DBNAME)
Вот то, что выдается как ошибка:
Traceback (most recent call last):
File “o:\ocsl\client\release\bin\scripts\estpro2std\main.py”, line 24, in ?
from gui.stdmain import *
File “o:\ocsl\client\release\bin\scripts\estpro2std\gui\stdmain.py”, line 33, in ?
from estpro2std.rules.rulesUtils import getConstant
File “o:\ocsl\client\release\bin\scripts\estpro2std\rules\rulesUtils.py”, line 19, in ?
from estpro2std.util.xmldb import OutworkPricedb
File “o:\ocsl\client\release\bin\scripts\estpro2std\util\xmldb.py”, line 19, in ?
from estpro2std.util.config import *
File “o:\ocsl\client\release\bin\scripts\estpro2std\util\config.py”, line 42, in ?
HOSTNAME = get_hostname(DBNAME)
File “o:\ocsl\client\release\bin\scripts\estpro2std\util\config.py”, line 38, in get_hostname
hostname = odbcRegistryKey
File “o:\ocsl\client\release\bin\scripts\lib\Win32Utils.py”, line 48, in __getitem__
raise KeyError, valueName
KeyError: Server