1 from __future__
import print_function
2 import coral,os,os.path
3 from RecoLuminosity.LumiDB
import cacheconfigParser,connectstrParser
7 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>''' 9 def __init__(self,connectString,authpath=None,siteconfpath=None,debugON = False):
13 usedefaultfrontierconfig =
False 16 self.__connectparser.parse()
17 if self.__connectparser.needsitelocalinfo():
19 cacheconfigpath = os.environ[
'CMS_PATH']
21 cacheconfigpath = os.path.join (cacheconfigpath,
'SITECONF',
'local',
'JobConfig',
'site-local-config.xml')
23 usedefaultfrontierconfig =
True 25 cacheconfigpath = siteconfpath
26 cacheconfigpath = os.path.join (cacheconfigpath,
'site-local-config.xml')
28 if usedefaultfrontierconfig:
31 ccp.parse (cacheconfigpath)
32 self.
__connectString = self.__connectparser.fullfrontierStr(self.__connectparser.schemaname(), ccp.parameterdict())
33 if self.__connectparser.protocol()==
'oracle':
35 os.environ[
'CORAL_AUTH_PATH']=authpath
37 os.environ[
'CORAL_AUTH_PATH']=
'.' 39 msg = coral.MessageStream (
'')
40 msg.setMsgVerbosity (coral.message_Level_Debug)
41 self.
__svc = coral.ConnectionService()
45 def openSession(self,isReadOnly=True,cpp2sqltype=[],sql2cpptype=[] ):
48 if self.__connectparser.protocol()==
'frontier' or isReadOnly:
49 session = self.__svc.connect(self.
__connectString, accessMode = coral.access_ReadOnly)
51 session = self.__svc.connect(self.
__connectString, accessMode = coral.access_Update)
52 for (cpptype,sqltype)
in cpp2sqltype:
53 session.typeConverter().setCppTypeForSqlType(cpptype,sqltype)
54 for (sqltype,cpptype)
in sql2cpptype:
55 session.typeConverter().setSqlTypeForCppType(sqltype,cpptype)
58 if session: del session
67 if __name__ ==
"__main__":
68 svc=
sessionManager(
'oracle://cms_orcoff_prep/cms_lumi_dev_offline',authpath=
'/afs/cern.ch/user/x/xiezhen',debugON=
False)
69 print(svc.realConnectString())
70 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
71 session.transaction().
start(
True)
72 session.transaction().commit()
74 svc=
sessionManager(
'frontier://LumiPrep/CMS_LUMI_DEV_OFFLINE',debugON=
False)
75 print(svc.realConnectString())
76 session=svc.openSession(isReadOnly=
True,cpp2sqltype=[(
'unsigned int',
'NUMBER(10)'),(
'unsigned long long',
'NUMBER(20)')])
S & print(S &os, JobReport::InputFile const &f)
def defaultfrontierConfigString()
def realConnectString(self)
def __init__(self, connectString, authpath=None, siteconfpath=None, debugON=False)
def openSession(self, isReadOnly=True, cpp2sqltype=[], sql2cpptype=[])