CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
o2olib.O2OMgr Class Reference
Inheritance diagram for o2olib.O2OMgr:
o2olib.O2OJobMgr

Public Member Functions

def __init__ (self)
 
def getSession (self, db_service, auth)
 
def logger (self)
 

Public Attributes

 eng
 
 logger
 

Detailed Description

Definition at line 98 of file o2olib.py.

Constructor & Destructor Documentation

def o2olib.O2OMgr.__init__ (   self)

Definition at line 99 of file o2olib.py.

99  def __init__(self):
100  self.logger = logging.getLogger()
101  self.logger.setLevel(logLevel)
102  consoleHandler = logging.StreamHandler(sys.stdout)
103  consoleHandler.setFormatter(logFormatter)
104  self.logger.addHandler(consoleHandler)
105  self.eng = None
106 
def __init__(self)
Definition: o2olib.py:99

Member Function Documentation

def o2olib.O2OMgr.getSession (   self,
  db_service,
  auth 
)

Definition at line 110 of file o2olib.py.

References o2olib.O2OMgr.eng, o2olib.get_db_credentials(), and harvestTrackValidationPlots.str.

110  def getSession( self, db_service, auth ):
111  url = None
112  if db_service is None:
113  url = private_db
114  else:
115  self.logger.info('Getting credentials')
116  if auth is not None:
117  if not os.path.exists(auth):
118  self.logger.error('Authentication path %s is invalid.' %auth)
119  return None
120  try:
121  username, pwd = get_db_credentials( db_service, auth )
122  except Exception as e:
123  logging.debug(str(e))
124  username = None
125  pwd = None
126  if username is None:
127  logging.error('Credentials for service %s (machine=%s) are not available' %(db_service[0],db_service[1]))
128  raise Exception("Cannot connect to db %s" %db_service[0] )
129  url = sqlalchemy_tpl %(username,pwd,db_service[0])
130  session = None
131  try:
132  self.eng = sqlalchemy.create_engine( url )
133  session = sqlalchemy.orm.scoped_session( sqlalchemy.orm.sessionmaker(bind=self.eng))
134  except sqlalchemy.exc.SQLAlchemyError as dberror:
135  self.logger.error( str(dberror) )
136  return session
137 
def getSession(self, db_service, auth)
Definition: o2olib.py:110
def get_db_credentials(db_service, authFile)
Definition: o2olib.py:64
def o2olib.O2OMgr.logger (   self)

Definition at line 107 of file o2olib.py.

References o2olib.O2OMgr.logger.

107  def logger( self ):
108  return self.logger
109 

Member Data Documentation

o2olib.O2OMgr.eng

Definition at line 105 of file o2olib.py.

Referenced by o2olib.O2OMgr.getSession().

o2olib.O2OMgr.logger

Definition at line 100 of file o2olib.py.

Referenced by o2olib.O2OMgr.logger().