ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/scripts/DBS/list
Revision: 1.1
Committed: Mon Jan 7 17:29:09 2008 UTC (17 years, 3 months ago) by auterman
Branch: MAIN
CVS Tags: HEAD
Branch point for: tex, Demo
Log Message:
Python script to query DBS

File Contents

# Content
1 #!/usr/bin/env python
2 #
3 # C.A. 7.1.2008, HH
4 #
5 #
6 import sys
7 #from dbsApi import DbsApi
8 from DBSAPI.dbsException import *
9 from DBSAPI.dbsApiException import *
10 from DBSAPI.dbsOptions import DbsOptionParser
11 from DBSAPI.dbsApi import DbsApi
12
13 try:
14 optManager = DbsOptionParser()
15 (opts,args) = optManager.getOpt()
16
17 #args={}
18 #args['url']='http://cmssrv17.fnal.gov:8989/DBS/servlet/DBSServlet'
19 #args['version']='DBS_1_0_4'
20 #args['mode']='POST'
21 #api = DbsApi(args)
22 args={}
23 args['url']='http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet'
24 #args['url']='https://cmsdbsprod.cern.ch:8443/cms_dbs_prod_global_writer/servlet/DBSServlet'
25 # levels are: CRITICAL, ERROR, NOTSET, DBSDEBUG, DBSINFO, DBSWARNING
26 args['level'] = 'ERROR'
27 args['version'] = 'DBS_1_0_5'
28
29 site={"se":"dcache-se-cms.desy.de"}
30
31 api = DbsApi(args)
32
33 # List all parameter sets
34 print "Processed Datasets:"
35 for ds in api.listProcessedDatasets(patternPrim='*QCD_Pt_*',
36 patternDT="*RECO*",
37 patternProc="*",
38 patternVer='CMSSW_1_6_7'):
39 FILENAME = ds['PrimaryDataset']['Name']+"_"+ds['Name']+".cff"
40 print FILENAME
41 f=open(FILENAME, 'w')
42 f.write("# "+ds['PathList'][0]+"\nsource = PoolSource {\nuntracked vstring fileNames = {\n")
43 files = api.listFiles(path=ds['PathList'][0])
44 f.write(",\n".join([' "%s"' % file['LogicalFileName'] for file in files]))
45 f.write("\n }\n}\n")
46 f.close()
47
48
49 except DbsApiException, ex:
50 print "Caught API Exception %s: %s " % (ex.getClassName(), ex.getErrorMessage() )
51 if ex.getErrorCode() not in (None, ""):
52 print "DBS Exception Error Code: ", ex.getErrorCode()
53
54 print "Done."
55