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 99 of file o2olib.py.

Constructor & Destructor Documentation

def o2olib.O2OMgr.__init__ (   self)

Definition at line 100 of file o2olib.py.

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

Member Function Documentation

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

Definition at line 111 of file o2olib.py.

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

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

Definition at line 108 of file o2olib.py.

References crabFunctions.CrabController.logger, and o2olib.O2OMgr.logger.

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

Member Data Documentation

o2olib.O2OMgr.eng

Definition at line 106 of file o2olib.py.

Referenced by o2olib.O2OMgr.getSession().

o2olib.O2OMgr.logger

Definition at line 101 of file o2olib.py.

Referenced by o2olib.O2OMgr.logger().