CMS 3D CMS Logo

Functions

dbsFileQuery Namespace Reference

Functions

def dbsFileQuery

Function Documentation

def dbsFileQuery::dbsFileQuery (   query)

Definition at line 1 of file dbsFileQuery.py.

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