CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
conddblib Namespace Reference

Classes

class  Connection
 
class  Enum
 
class  EnumMetaclass
 
class  GlobalTag
 
class  GlobalTagMap
 
class  IOV
 
class  Payload
 
class  Synchronization
 
class  Tag
 
class  TimeType
 

Functions

def _getCMSFrontierConnectionString
 
def _getCMSFrontierSQLAlchemyConnectionString
 
def _getCMSOracleSQLAlchemyConnectionString
 
def connect
 
def hash
 

Variables

string __author__ = 'Miguel Ojeda'
 
string __copyright__ = 'Copyright 2013, CERN'
 
list __credits__ = ['Giacomo Govi', 'Miguel Ojeda', 'Andreas Pfeiffer']
 
string __email__ = 'mojedasa@cern.ch'
 
string __license__ = 'Unknown'
 
string __maintainer__ = 'Miguel Ojeda'
 
tuple _Base = sqlalchemy.ext.declarative.declarative_base()
 
string contact_help = 'If you need assistance, please write an email to %s and %s. If you need immediate/urgent assistance, you can call the Offline DB expert on call (%s).'
 
string database_help
 
int description_length = 4000
 
string empty_label = '-'
 
tuple hash_length = len(hash(''))
 
tuple logger = logging.getLogger(__name__)
 
int name_length = 100
 
string offline_db_experts_email = 'cms-offlinedb-exp@cern.ch'
 
string offline_db_experts_phone = '+41 22 76 70817, or 70817 from CERN; check https://twiki.cern.ch/twiki/bin/viewauth/CMS/DBShifterHelpPage if it does not work; availability depends on the state of the LHC'
 
string web_experts_email = 'cms-cond-dev@cern.ch'
 

Detailed Description

CMS Conditions DB Python library.

Function Documentation

def conddblib._getCMSFrontierConnectionString (   database)
private

Definition at line 334 of file conddblib.py.

References communicate().

Referenced by _getCMSFrontierSQLAlchemyConnectionString().

335 def _getCMSFrontierConnectionString(database):
336  import subprocess
337  return subprocess.Popen(['cmsGetFnConnect', 'frontier://%s' % database], stdout = subprocess.PIPE).communicate()[0].strip()
338 
static void * communicate(void *obj)
Definition: DQMNet.cc:1246
def _getCMSFrontierConnectionString
Definition: conddblib.py:334
def conddblib._getCMSFrontierSQLAlchemyConnectionString (   database,
  schema = 'cms_conditions' 
)
private

Definition at line 339 of file conddblib.py.

References _getCMSFrontierConnectionString().

Referenced by connect().

340 def _getCMSFrontierSQLAlchemyConnectionString(database, schema = 'cms_conditions'):
341  import urllib
342  return 'oracle+frontier://@%s/%s' % (urllib.quote_plus(_getCMSFrontierConnectionString(database)), schema)
343 
def _getCMSFrontierConnectionString
Definition: conddblib.py:334
def _getCMSFrontierSQLAlchemyConnectionString
Definition: conddblib.py:339
def conddblib._getCMSOracleSQLAlchemyConnectionString (   database,
  schema = 'cms_conditions' 
)
private

Definition at line 344 of file conddblib.py.

Referenced by connect().

345 def _getCMSOracleSQLAlchemyConnectionString(database, schema = 'cms_conditions'):
346  return 'oracle://%s@%s' % (schema, database)
347 
348 
# Entry point
def _getCMSOracleSQLAlchemyConnectionString
Definition: conddblib.py:344
def conddblib.connect (   database = 'pro',
  init = False,
  verbose = 0 
)
Returns a Connection instance to the CMS Condition DB.

See database_help for the description of the database parameter.

The verbosity level is as follows:

    0 = No output (default).
    1 = SQL statements issued, including their parameters.
    2 = In addition, results of the queries (all rows and the column headers).

Definition at line 349 of file conddblib.py.

References _getCMSFrontierSQLAlchemyConnectionString(), and _getCMSOracleSQLAlchemyConnectionString().

350 def connect(database='pro', init=False, verbose=0):
351  '''Returns a Connection instance to the CMS Condition DB.
352 
353  See database_help for the description of the database parameter.
354 
355  The verbosity level is as follows:
356 
357  0 = No output (default).
358  1 = SQL statements issued, including their parameters.
359  2 = In addition, results of the queries (all rows and the column headers).
360  '''
361 
362  # Lazy in order to avoid calls to cmsGetFnConnect
363  mapping = {
364  'pro': lambda: _getCMSFrontierSQLAlchemyConnectionString('PromptProd'),
365  'arc': lambda: _getCMSFrontierSQLAlchemyConnectionString('FrontierArc'),
366  'int': lambda: _getCMSFrontierSQLAlchemyConnectionString('FrontierInt'),
367  'dev': lambda: _getCMSFrontierSQLAlchemyConnectionString('FrontierPrep'),
368  'boost': lambda: _getCMSFrontierSQLAlchemyConnectionString('FrontierProd', 'cms_conditions'),
369  'boostprep': lambda: _getCMSFrontierSQLAlchemyConnectionString('FrontierPrep', 'cms_conditions'),
370 
371  'orapro': lambda: _getCMSOracleSQLAlchemyConnectionString('cms_orcon_adg'),
372  'oraarc': lambda: _getCMSOracleSQLAlchemyConnectionString('cmsarc_lb'),
373  'oraint': lambda: _getCMSOracleSQLAlchemyConnectionString('cms_orcoff_int'),
374  'oradev': lambda: _getCMSOracleSQLAlchemyConnectionString('cms_orcoff_prep'),
375  'oraboost': lambda: _getCMSOracleSQLAlchemyConnectionString('cms_orcon_adg' , 'cms_conditions'),
376  'oraboostprep': lambda: _getCMSOracleSQLAlchemyConnectionString('cms_orcoff_prep', 'cms_conditions'),
377 
378  'onlineorapro': lambda: _getCMSOracleSQLAlchemyConnectionString('cms_orcon_prod'),
379  'onlineoraint': lambda: _getCMSOracleSQLAlchemyConnectionString('cmsintr_lb'),
380  }
381 
382  if database in mapping:
383  database = mapping[database]()
384 
385  try:
386  url = sqlalchemy.engine.url.make_url(database)
387  if url.drivername == 'oracle' and url.password is None:
388  import getpass
389  url.password = getpass.getpass('Password for %s: ' % str(url))
390  except sqlalchemy.exc.ArgumentError:
391  url = sqlalchemy.engine.url.make_url('sqlite:///%s' % database)
392 
393  if verbose >= 1:
394  logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
395 
396  if verbose >= 2:
397  logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)
398 
399  return Connection(url, init=init)
400 
def _getCMSOracleSQLAlchemyConnectionString
Definition: conddblib.py:344
def connect
Definition: conddblib.py:349
def _getCMSFrontierSQLAlchemyConnectionString
Definition: conddblib.py:339
def conddblib.hash (   data)

Definition at line 63 of file conddblib.py.

63 
64 def hash(data):
65  return hashlib.sha1(data).hexdigest()
66 
67 
# Constants
def hash
Definition: conddblib.py:63

Variable Documentation

string conddblib.__author__ = 'Miguel Ojeda'

Definition at line 4 of file conddblib.py.

string conddblib.__copyright__ = 'Copyright 2013, CERN'

Definition at line 5 of file conddblib.py.

list conddblib.__credits__ = ['Giacomo Govi', 'Miguel Ojeda', 'Andreas Pfeiffer']

Definition at line 6 of file conddblib.py.

string conddblib.__email__ = 'mojedasa@cern.ch'

Definition at line 9 of file conddblib.py.

string conddblib.__license__ = 'Unknown'

Definition at line 7 of file conddblib.py.

string conddblib.__maintainer__ = 'Miguel Ojeda'

Definition at line 8 of file conddblib.py.

tuple conddblib._Base = sqlalchemy.ext.declarative.declarative_base()

Definition at line 168 of file conddblib.py.

string conddblib.contact_help = 'If you need assistance, please write an email to %s and %s. If you need immediate/urgent assistance, you can call the Offline DB expert on call (%s).'

Definition at line 78 of file conddblib.py.

string conddblib.database_help

Definition at line 79 of file conddblib.py.

int conddblib.description_length = 4000

Definition at line 71 of file conddblib.py.

string conddblib.empty_label = '-'

Definition at line 68 of file conddblib.py.

tuple conddblib.hash_length = len(hash(''))

Definition at line 72 of file conddblib.py.

tuple conddblib.logger = logging.getLogger(__name__)

Definition at line 20 of file conddblib.py.

Referenced by cscdqm::Configuration.printStats().

int conddblib.name_length = 100

Definition at line 70 of file conddblib.py.

string conddblib.offline_db_experts_email = 'cms-offlinedb-exp@cern.ch'

Definition at line 75 of file conddblib.py.

string conddblib.offline_db_experts_phone = '+41 22 76 70817, or 70817 from CERN; check https://twiki.cern.ch/twiki/bin/viewauth/CMS/DBShifterHelpPage if it does not work; availability depends on the state of the LHC'

Definition at line 76 of file conddblib.py.

string conddblib.web_experts_email = 'cms-cond-dev@cern.ch'

Definition at line 74 of file conddblib.py.