Example #1
0
 def initDB(self, authPath=None, dbName=None):
     if (authPath == None):
         authPath = self.authPath
     if (dbName == None):
         dbName = self.dbName
     else:
         self.dbName = dbName
     if dbName.startswith('frontier'):
         self.rdbms = CondDB.RDBMS('')
         self.db = self.rdbms.getReadOnlyDB(str(dbName))
     else:
         self.rdbms = CondDB.RDBMS(authPath)
         self.db = self.rdbms.getDB(dbName)
Example #2
0
    def initGT(self, globalTagName, connectionString=None, authPath=None):
        """
        Initiates the connection to the GT database, or re-initiates it in case one of the connection parameters is changed, and loads the Global Tag.
        Parameters:
        globalTagName: name of the Global Tag;
        connectionString: connection string for connecting to the account hosting Global Tags (default None if unchanged w.r.t. c'tor);
        authPath: path to authentication key (default None if unchanged w.r.t. c'tor).
        @returns: a boolean set to True if the connection has been (re-)opened; raises if the connection cannot be established.
        """
        isReconnected = False
        if authPath != None and self._authPath != authPath:
            self._authPath = authPath
            self._dbStarted = False
        if connectionString != None and self._connectionString != connectionString:
            checkConnectionString(connectionString)
            self._connectionString = connectionString
            self._dbStarted = False
        if self._globalTagName == globalTagName and self._dbStarted:
            return isReconnected
        if self._globalTagName != globalTagName:
            self._globalTagName = globalTagName
            self._dbStarted = False
        try:
            self._rdbms = condDB.RDBMS(self._authPath)
            self._globalTag = self._rdbms.globalTag(
                self._connectionString, "::".join([self._globalTagName,
                                                   "All"]), "", "")
            self._dbStarted = True
            isReconnected = True
        except RuntimeError as err:
            raise conditionError.ConditionError(
                """Cannot connect to Global Tag \"%s\" on account \"%s\" for RDBMS in \"%s\".
The CMSSW exception is: %s""" % (self._globalTagName, self._connectionString,
                                 self._authPath, err))
        return isReconnected
Example #3
0
    def _initDB(self, connectionString, authPath=None):
        """
        Initiates the connection to the database, or re-initiates it in case one of the connection parameters is changed.
        Parameters:
        connectionString: connection string for connecting to the account specified by the connection string;
        authPath: path to authentication key  (default None if unchanged w.r.t. c'tor).
        @returns: a boolean set to True if the connection has been (re-)opened; raises if the connection cannot be established.
        """
        isReconnected = False
        if authPath != None and self._authPath != authPath:
            self._authPath = authPath
            self._dbStarted = False
        if self._connectionString == connectionString and self._dbStarted:
            return isReconnected
        if self._connectionString != connectionString:
            checkConnectionString(connectionString)
            self._connectionString = str(
                connectionString
            )  # ensure we pass on a string even if we get a unicode object
            self._dbStarted = False
        try:
            self._rdbms = condDB.RDBMS(self._authPath)
            self._db = self._rdbms.getReadOnlyDB(
                str(self._connectionString)
            )  # ensure we pass on a string even if we get a unicode object
            isReconnected = True
            self._dbStarted = True
        except RuntimeError as err:
            raise conditionError.ConditionError(
                """Cannot connect to condition database \"%s\" for RDBMS in \"%s\".
The CMSSW exception is: %s""" % (self._connectionString, self._authPath, err))
        return isReconnected
Example #4
0
def list_tag(conn_str, tag, auth_path):
    rdbms = condDB.RDBMS(auth_path)
    db = rdbms.getReadOnlyDB(conn_str)
    db.startReadOnlyTransaction()
    iov = db.iov(tag)
    for elem in iov.elements:
        print(elem.since())
        db.commitTransaction()
Example #5
0
 def initDB(self, authPath=None, dbName=None):
     if (authPath == None):
         authPath = self.authPath
     else:
         self.authPath = authPath
     if (dbName == None):
         dbName = self.dbName
     else:
         self.dbName = dbName
     try:
         self.rdbms = condDB.RDBMS(self.authPath)
         self.db = self.rdbms.getReadOnlyDB(self.dbName)
     except:
         raise TypeError("Cannot connect to \"" + self.dbName +
                         "\" for RDBMS in \"" + self.authPath + "\"")
Example #6
0
    def _initGT(self, authpath=None, global_tag_schema=None, log_schema=None):
        '''Iniciate connection to DB containing information about GT'''

        #if auth path not given - take from constructor variable
        if (authpath == None):
            authpath = self.authpath
        else:
            self.authpath = authpath

        if (global_tag_schema == None):
            global_tag_schema = self.global_tag_schema
        else:
            self.global_tag_schema = global_tag_schema

        if (log_schema == None):
            log_schema = self.log_schema
        else:
            self.log_schema = log_schema

        self.framework_incantation = condDB.FWIncantation()
        self.rdbms = condDB.RDBMS(self.authpath)
        self.rdbms.setLogger(self.log_schema)
Example #7
0
from __future__ import print_function
import DLFCN, sys, os
sys.setdlopenflags(DLFCN.RTLD_GLOBAL + DLFCN.RTLD_LAZY)
import pluginCondDBPyInterface as condDB
a = condDB.FWIncantation()
rdbms = condDB.RDBMS()
conn = "frontier://FrontierPrep/CMS_COND_STRIP"  # for develoment DB
conn = "frontier://FrontierInt/CMS_COND_STRIP"  # for integration DB (as agreed to do tests)
conn = "frontier://PromptProd/CMS_COND_31X_STRIP"
db = rdbms.getReadOnlyDB(conn)
tag = "SiStripLatency_GR10_v2_hlt"
db.startReadOnlyTransaction()
iov = db.iov(tag)
# print list(db.payloadModules(tag))
Plug = __import__(str(db.payloadModules(tag)[0]))
payload = Plug.Object(db)
listOfIovElem = [iovElem for iovElem in iov.elements]

runNumber = 0

if len(sys.argv) >= 2:
    runNumber = int(sys.argv[1])

for elem in iov.elements:
    if runNumber == 0 or (runNumber >= elem.since()
                          and runNumber <= elem.till()):
        theIOV = payload.load(elem)
        if theIOV:
            payload.dumpXML("dump_" + str(elem.since()) + ".xml")
            if payload.summary().find("PEAK") != -1:
                print("since =", elem.since(), ", till =", elem.till(),