CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/HLTrigger/Configuration/python/Tools/dbsFileQuery.py

Go to the documentation of this file.
00001 def dbsFileQuery(query):
00002   # load the DBS API
00003   import sys, os
00004   dbsapipath = os.environ['DBSCMD_HOME']
00005   if dbsapipath not in sys.path:
00006     sys.path.append(dbsapipath)
00007 
00008   from dbsApi import DbsApi
00009   api = DbsApi()
00010 
00011   # run the query, which should be of the form 'find file where ...'
00012   results = api.executeQuery(query)
00013 
00014   # parse the results in XML format, and extract the list of files
00015   from xml.dom.minidom import parseString
00016   xml = parseString(results)
00017 
00018   files = []
00019 
00020   for results in xml.getElementsByTagName('results'):
00021     for row in results.getElementsByTagName('row'):
00022       for file in row.getElementsByTagName('file'):
00023         files.append( file.firstChild.data )
00024 
00025   return files