Example #1
0
def dbsGetDatasetType( dataset ):
    d = {}
    d['url']='http://cmsdbsprod.cern.ch/cms_dbs_ph_analysis_02/servlet/DBSServlet'
    d['quiet']=True
    api = DbsApi( d )
    print api.listDatasetSummary(dataset.name)
    res = api.executeQuery('find datatype where dataset=%s' % dataset.name)
Example #2
0
def getFileNames (event, dbsOptions = {}):
    # Query DBS
    try:
        api = DbsApi (dbsOptions)
        query = "find file where dataset=%(dataset)s and run=%(run)i and lumi=%(lumi)i" % event

        xmldata = api.executeQuery(query)
    except DbsApiException, ex:
        print "Caught API Exception %s: %s "  % (ex.getClassName(), ex.getErrorMessage() )
        if ex.getErrorCode() not in (None, ""):
            print "DBS Exception Error Code: ", ex.getErrorCode()
def getFileNames(event, dbsOptions={}):
    # Query DBS
    try:
        api = DbsApi(dbsOptions)
        query = "find file where dataset=%(dataset)s and run=%(run)i and lumi=%(lumi)i" % event

        xmldata = api.executeQuery(query)
    except DbsApiException, ex:
        print "Caught API Exception %s: %s " % (ex.getClassName(),
                                                ex.getErrorMessage())
        if ex.getErrorCode() not in (None, ""):
            print "DBS Exception Error Code: ", ex.getErrorCode()
Example #4
0
def getDataset(filename):
    "Interface with the DBS API to get the dataset used"
    from xml.dom.minidom import parseString
    from DBSAPI.dbsApi import DbsApi
    args = {}
    args['url']='http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet'
    args['version']='DBS_2_0_9'
    args['mode']='POST'
    api = DbsApi(args)
    data = api.executeQuery("find dataset where file="+filename)
    domresults = parseString(data)
    dbs = domresults.getElementsByTagName('dbs')
    result = dbs[0].getElementsByTagName('results')
    rows=result[0].getElementsByTagName('row')
    dataset=(rows[0].getElementsByTagName('dataset'))[0] #rows should have only one element and produce a one element array
    node=(dataset.childNodes)[0] #childNodes should be a one element array
    return str(node.data) #The output is in unicode, so it has to be translated through str
Example #5
0
def get_dbs_info(toFind, requirements):
    "Interface with the DBS API to get the whatever you want of a requirements. ALWAYS RETURN A LIST OF STRINGS"
    args = {}
    args['url']='http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet'
    args['version']='DBS_2_0_9'
    args['mode']='POST'
    api = DbsApi(args)
    data = api.executeQuery("find %s where %s" % (toFind, requirements))
    domresults = parseString(data)
    dbs = domresults.getElementsByTagName('dbs')
    result = dbs[0].getElementsByTagName('results')
    rows=result[0].getElementsByTagName('row')
    retList = []
    for row in rows:
        resultXML = row.getElementsByTagName(toFind)[0]
        node=(resultXML.childNodes)[0] #childNodes should be a one element array
        retList.append(str(node.nodeValue))
    return retList
Example #6
0
from DBSAPI.dbsApiException import *
from DBSAPI.dbsOptions import DbsOptionParser
from DBSAPI.dbsApi import DbsApi
from DBSAPI.dbsOptions import DbsOptionParser
from xml.sax import SAXParseException
#
#
if __name__ == "__main__":

    # Query DBS
    try:
  	optManager  = DbsOptionParser()
  	(opts,args) = optManager.getOpt()
  	api = DbsApi(opts.__dict__)
	query="find file where dataset=/Commissioning2008Ecal-A/Online/RAW and run=39457 and lumi=1"
	xmldata = api.executeQuery(query)

    except DbsApiException, ex:
  		print "Caught API Exception %s: %s "  % (ex.getClassName(), ex.getErrorMessage() )
  		if ex.getErrorCode() not in (None, ""):
    			print "DBS Exception Error Code: ", ex.getErrorCode()      

    # Parse the resulting xml output.
    files = []
    try:
      class Handler (xml.sax.handler.ContentHandler):

        def startElement(self, name, attrs):
          if name == 'result':
            files.append(str(attrs['FILES_LOGICALFILENAME']))
Example #7
0
if __name__ == "__main__":

        try:
                optManager  = DbsQueryOptionParser()
                (opts,args) = optManager.parse_args()
                opts = opts.__dict__

                if opts['url'] in ('', None, 'BADURL'):
			configDict = DbsConfig(opts)
			opts['url'] = str(configDict.url())

                if opts['query'] in (None, ""):
                        print "You must specify a query, Use --query=, look at --help"
                        sys.exit(0)

                api = DbsApi(opts)
		print opts['query']
		#print api.executeQuery(opts['query'], 2, 5, "query")
		#print api.executeQuery(opts['query'], 1,5,type="exe")
		#print api.executeQuery(opts['query'], ignoreCase=False)
		print api.executeQuery(opts['query'])
  		#print api.executeQuery("select file,ls where path=/GlobalMar08-Express/Online/RAW")

	except DbsApiException, ex:
  		print "Caught API Exception %s: %s "  % (ex.getClassName(), ex.getErrorMessage() )
  		if ex.getErrorCode() not in (None, ""):
    			print "DBS Exception Error Code: ", ex.getErrorCode()      
			print "I am herererrrrrrrrrrrrrrrrrrrrrrr->>>>>>>>>>>>>>>"

Example #8
0
if __name__ == "__main__":

    try:
        optManager = DbsQueryOptionParser()
        (opts, args) = optManager.parse_args()
        opts = opts.__dict__

        if opts['url'] in ('', None, 'BADURL'):
            configDict = DbsConfig(opts)
            opts['url'] = str(configDict.url())

        if opts['query'] in (None, ""):
            print "You must specify a query, Use --query=, look at --help"
            sys.exit(0)

        api = DbsApi(opts)
        print opts['query']
        #print api.executeQuery(opts['query'], 2, 5, "query")
        #print api.executeQuery(opts['query'], 1,5,type="exe")
        #print api.executeQuery(opts['query'], ignoreCase=False)
        print api.executeQuery(opts['query'])
#print api.executeQuery("select file,ls where path=/GlobalMar08-Express/Online/RAW")

    except DbsApiException, ex:
        print "Caught API Exception %s: %s " % (ex.getClassName(),
                                                ex.getErrorMessage())
        if ex.getErrorCode() not in (None, ""):
            print "DBS Exception Error Code: ", ex.getErrorCode()
            print "I am herererrrrrrrrrrrrrrrrrrrrrrr->>>>>>>>>>>>>>>"
Example #9
0
#!/usr/bin/env python

import os, sys
from DBSAPI.dbsApi import DbsApi

dbsUrl="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet"
config={'url':dbsUrl,'mode':'POST','version':'DBS_1_2_2','retry':2}
dbsApi=DbsApi(config)
print dbsApi,sys.version
userInput="find datasesssssss where dataset like *"
try:
   res=dbsApi.executeQuery(userInput,begin=0,end=10,type="query")
   print res
except:
   import traceback
   traceback.print_exc()
   pass