1 import coral,os,os.path
2 from RecoLuminosity.LumiDB
import cacheconfigParser,connectstrParser
6 return '''<frontier-connect><proxy url = "http://cmst0frontier.cern.ch:3128"/><proxy url = "http://cmst0frontier.cern.ch:3128"/><proxy url = "http://cmst0frontier1.cern.ch:3128"/><proxy url = "http://cmst0frontier2.cern.ch:3128"/><server url = "http://cmsfrontier.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier1.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier2.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier3.cern.ch:8000/FrontierInt"/><server url = "http://cmsfrontier4.cern.ch:8000/FrontierInt"/></frontier-connect>'''
8 def __init__(self,connectString,authpath=None,siteconfpath=None,debugON = False):
12 usedefaultfrontierconfig =
False
15 self.__connectparser.parse()
16 if self.__connectparser.needsitelocalinfo():
18 cacheconfigpath = os.environ[
'CMS_PATH']
20 cacheconfigpath = os.path.join (cacheconfigpath,
'SITECONF',
'local',
'JobConfig',
'site-local-config.xml')
22 usedefaultfrontierconfig =
True
24 cacheconfigpath = siteconfpath
25 cacheconfigpath = os.path.join (cacheconfigpath,
'site-local-config.xml')
27 if usedefaultfrontierconfig:
30 ccp.parse (cacheconfigpath)
31 self.
__connectString = self.__connectparser.fullfrontierStr(self.__connectparser.schemaname(), ccp.parameterdict())
32 if self.__connectparser.protocol()==
'oracle':
34 os.environ[
'CORAL_AUTH_PATH']=authpath
36 os.environ[
'CORAL_AUTH_PATH']=
'.'
38 msg = coral.MessageStream (
'')
39 msg.setMsgVerbosity (coral.message_Level_Debug)
40 self.
__svc = coral.ConnectionService()
44 def openSession(self,isReadOnly=True,cpp2sqltype=[],sql2cpptype=[] ):
47 if self.__connectparser.protocol()==
'frontier' or isReadOnly:
48 session = self.__svc.connect(self.
__connectString, accessMode = coral.access_ReadOnly)
50 session = self.__svc.connect(self.
__connectString, accessMode = coral.access_Update)
51 for (cpptype,sqltype)
in cpp2sqltype:
52 session.typeConverter().setCppTypeForSqlType(cpptype,sqltype)
53 for (sqltype,cpptype)
in sql2cpptype:
54 session.typeConverter().setSqlTypeForCppType(sqltype,cpptype)
57 if session: del session
66 if __name__ ==
"__main__":
67 svc=
sessionManager(
'oracle://cms_orcoff_prep/cms_lumi_dev_offline',authpath=
'/afs/cern.ch/user/x/xiezhen',debugON=
False)
68 print svc.realConnectString()
69 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
70 session.transaction().
start(
True)
71 session.transaction().commit()
73 svc=
sessionManager(
'frontier://LumiPrep/CMS_LUMI_DEV_OFFLINE',debugON=
False)
74 print svc.realConnectString()
75 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
def defaultfrontierConfigString