ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/InspectDBS2.py
Revision: 1.2
Committed: Fri Jul 18 10:17:36 2008 UTC (16 years, 9 months ago) by afanfani
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_9_1, CRAB_2_9_1_pre2, CRAB_2_9_1_pre1, CRAB_2_9_0, CRAB_2_9_0_pre2, CRAB_2_9_0_pre1, CRAB_2_8_8, CRAB_2_8_8_pre1, CRAB_2_8_7_patch3, CRAB_2_8_7_patch2, CRAB_2_8_7_patch1, CRAB_2_8_7, CRAB_2_8_7_pre2, CRAB_2_8_7_pre1, CRAB_2_8_6, CRAB_2_8_6_pre1, CRAB_2_8_5_patch3, CRAB_2_8_5_patch2, CRAB_2_8_5_patch1, CRAB_2_8_5, CRAB_2_8_5_pre5, CRAB_2_8_5_pre4, CRAB_2_8_5_pre3, CRAB_2_8_4_patch3, CRAB_2_8_5_pre2, CRAB_2_8_4_patch2, CRAB_2_8_5_pre1, CRAB_2_8_4_patch1, CRAB_2_8_4, CRAB_2_8_4_pre5, CRAB_2_8_4_pre4, CRAB_2_8_4_pre3, CRAB_2_8_4_pre2, CRAB_2_8_4_pre1, CRAB_2_8_3, CRAB_2_8_3_pre4, CRAB_2_8_3_pre3, CRAB_2_8_3_pre2, CRAB_2_8_3_pre1, CRAB_2_8_2_patch1, CRAB_2_8_2, CRAB_2_8_2_pre5, CRAB_2_8_2_pre4, CRAB_2_8_2_pre3, CRAB_2_8_2_pre2, CRAB_2_8_2_pre1, CRAB_2_8_1, CRAB_2_8_0, CRAB_2_8_0_pre1, CRAB_2_7_10_pre3, CRAB_2_7_9_patch2_pre1, CRAB_2_7_10_pre2, CRAB_2_7_10_pre1, CRAB_2_7_9_patch1, CRAB_2_7_9, CRAB_2_7_9_pre5, CRAB_2_7_9_pre4, CRAB_2_7_9_pre3, CRAB_2_7_9_pre2, CRAB_2_7_8_patch2, CRAB_2_7_9_pre1, CRAB_2_7_8_patch2_pre1, CRAB_2_7_8_patch1, CRAB_2_7_8_patch1_pre1, CRAB_2_7_8, CRAB_2_7_8_pre3, CRAB_2_7_8_pre2, CRAB_2_7_8_dash3, CRAB_2_7_8_dash2, CRAB_2_7_8_dash, CRAB_2_7_7_patch1, CRAB_2_7_7_patch1_pre1, CRAB_2_7_8_pre1, CRAB_2_7_7, CRAB_2_7_7_pre2, CRAB_2_7_7_pre1, CRAB_2_7_6_patch1, CRAB_2_7_6, CRAB_2_7_6_pre1, CRAB_2_7_5_patch1, CRAB_2_7_5, CRAB_2_7_5_pre3, CRAB_2_7_5_pre2, CRAB_2_7_5_pre1, CRAB_2_7_4_patch1, CRAB_2_7_4, CRAB_2_7_4_pre6, CRAB_2_7_4_pre5, CRAB_2_7_4_pre4, CRAB_2_7_4_pre3, CRAB_2_7_4_pre2, CRAB_2_7_4_pre1, CRAB_2_7_3, CRAB_2_7_3_pre3, CRAB_2_7_3_pre3_beta, CRAB_2_7_3_pre2, CRAB_2_7_3_pre2_beta, CRAB_2_7_3_pre1, CRAB_2_7_3_beta3, CRAB_2_7_3_beta2, CRAB_2_7_3_beta1, CRAB_2_7_3_beta, CRAB_2_7_2_p1, CRAB_2_7_1_branch_firstMERGE, CRAB_2_7_2, CRAB_2_7_2_pre4, CRAB_2_7_2_pre3, CRAB_2_7_2_pre2, CRAB_2_7_2_pre1, CRAB_2_7_1, fede_170310, CRAB_2_7_1_pre12, CRAB_2_7_1_pre11, CRAB_2_7_1_pre10, CRAB_2_7_1_pre9, CRAB_LumiMask, CRAB_2_7_lumi, from_LimiMask, CRAB_2_7_1_pre8, CRAB_2_7_1_pre6, CRAB_2_7_1_pre5, CRAB_2_7_1_wmbs_pre4, CRAB_2_7_1_pre4, CRAB_2_7_1_pre3, CRAB_2_6_6_pre6, CRAB_2_7_1_pre2, CRAB_2_6_6_pre5, CRAB_2_7_1_pre1, CRAB_2_6_6_pre4, CRAB_2_6_6_pre3, CRAB_2_6_6_pre2, CRAB_2_6_6_check, CRAB_2_6_6, CRAB_2_6_6_pre1, CRAB_2_7_0, CRAB_2_6_5, CRAB_2_7_0_pre8, CRAB_2_6_5_pre1, CRAB_2_7_0_pre7, CRAB_2_6_4, CRAB_2_7_0_pre6, CRAB_2_6_4_pre1, CRAB_2_7_0_pre5, CRAB_2_6_3_patch_2, CRAB_2_6_3_patch_2_pre2, CRAB_2_6_3_patch_2_pre1, CRAB_2_6_3_patch_1, CRAB_2_7_0_pre4, CRAB_2_7_0_pre3, CRAB_2_6_3, CRAB_2_6_3_pre5, CRAB_2_6_3_pre4, CRAB_2_6_3_pre3, CRAB_2_6_3_pre2, CRAB_2_7_0_pre2, CRAB_2_6_3_pre1, test_1, CRAB_2_7_0_pre1, CRAB_2_6_2, CRAB_2_6_2_pre2, CRAB_2_6_2_pre1, CRAB_2_6_1_pre4, CRAB_2_6_1_pre3, CRAB_2_6_1_pre2, CRAB_2_6_1_pre1, CRAB_2_6_1, CRAB_2_6_0, CRAB_2_6_0_pre14, CRAB_2_6_0_pre13, CRAB_2_6_0_pre12, CRAB_2_6_0_pre11, CRAB_2_6_0_pre10, CRAB_2_6_0_pre9, CRAB_2_6_0_pre8, CRAB_2_6_0_pre7, CRAB_2_6_0_pre6, CRAB_2_6_0_pre5, CRAB_2_6_0_pre4, CRAB_2_6_0_pre3, CRAB_2_6_0_pre2, CRAB_2_6_0_pre1, CRAB_2_5_1, CRAB_2_5_1_pre4, CRAB_2_5_1_pre3, CRAB_2_5_1_pre2, CRAB_2_5_1_pre1, CRAB_2_5_0, CRAB_2_5_0_pre7, CRAB_2_5_0_pre6, CRAB_2_5_0_pre5, CRAB_2_5_0_pre4, CRAB_2_5_0_pre3, CRAB_2_5_0_pre2, CRAB_2_5_0_pre1, CRAB_2_4_4, CRAB_2_4_4_pre6, CRAB_2_4_4_pre5, CRAB_2_4_4_pre4, CRAB_2_4_4_pre3, CRAB_2_4_4_pre2, CRAB_2_4_4_pre1, CRAB_2_4_3, CRAB_2_4_3_pre8, CRAB_2_4_3_pre7, CRAB_2_4_3_pre6, CRAB_2_4_3_pre5, CRAB_2_4_3_pre3, CRAB_2_4_3_pre2, CRAB_2_4_3_pre1, CRAB_2_4_2, CRAB_2_4_2_pre3, CRAB_2_4_2_pre2, CRAB_2_4_2_pre1, CRAB_2_4_1, CRAB_2_4_1_pre4, CRAB_2_4_1_pre3, CRAB_2_4_1_pre2, CRAB_2_4_1_pre1, CRAB_2_4_0_Tutorial, CRAB_2_4_0_Tutorial_pre1, CRAB_2_4_0, CRAB_2_4_0_pre9, CRAB_2_4_0_pre8, CRAB_2_4_0_pre7, CRAB_2_4_0_pre6, CRAB_2_4_0_pre5, CRAB_2_4_0_pre4, CRAB_2_4_0_pre3, CRAB_2_4_0_pre2, CRAB_2_4_0_pre1, CRAB_DLS_PHED1, CRAB_DLS_PHED, CRAB_2_3_2_Fnal, CRAB_2_3_2, CRAB_2_3_2_pre7, CRAB_2_3_2_pre5, CRAB_2_3_2_pre4, CRAB_2_3_2_pre3, CRAB_2_3_2_pre2, CRAB_2_3_2_pre1, HEAD
Branch point for: CRAB_multiout, CRAB_2_7_1_branch, Lumi2_8, CRAB_2_6_X_br, AnaDataSet
Changes since 1.1: +2 -1 lines
Log Message:
default to global DBS

File Contents

# User Rev Content
1 fanzago 1.1 #!/usr/bin/env python
2     import sys
3     for p in sys.path:
4     if p.find( "python2.3/lib-dynload" ) != -1 :
5     sys.path.pop( sys.path.index(p) )
6     ##
7    
8     from ProdCommon.DataMgmt.DBS.DBSWriter import DBSWriter
9     from ProdCommon.DataMgmt.DBS.DBSReader import DBSReader
10     from ProdCommon.DataMgmt.DBS.DBSErrors import DBSWriterError, formatEx
11     from DBSAPI.dbsApiException import DbsException
12     #
13     import os,getopt
14    
15     # //
16     # // Get DBS instance to use
17     # //
18     usage="\n Usage: python InspectDBS2.py <options> \n Options: \n --datasetPath=/primarydataset/procdataset/tier \t\t dataset path \n --DBSURL=<URL> \t\t DBS URL \n --help \t\t\t\t print this help \n"
19     valid = ['DBSURL=','datasetPath=','full','help']
20     try:
21     opts, args = getopt.getopt(sys.argv[1:], "", valid)
22     except getopt.GetoptError, ex:
23     print usage
24     print str(ex)
25     sys.exit(1)
26    
27     #url = "http://cmssrv17.fnal.gov:8989/DBS/servlet/DBSServlet"
28 afanfani 1.2 #url = "http://cmssrv17.fnal.gov:8989/DBS108LOC1/servlet/DBSServlet"
29     url = "http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet"
30 fanzago 1.1
31     datasetPath = None
32     full = False
33    
34     for opt, arg in opts:
35     if opt == "--DBSURL":
36     url = arg
37     if opt == "--datasetPath":
38     datasetPath = arg
39     if opt == "--full":
40     full = True
41     if opt == "--help":
42     print usage
43     sys.exit(1)
44    
45     if datasetPath == None:
46     print "--datasetPath option not provided. For example : --datasetPath /primarydataset/processeddataset/datatier"
47     print usage
48     sys.exit()
49     print ">>>>> DBS URL : %s"%(url,)
50    
51    
52     import logging
53     logging.disable(logging.INFO)
54    
55     # //
56     # // Get API to DBS
57     #//
58     dbsreader = DBSReader(url)
59     # //
60     # // Get list of datasets
61     #//
62     if datasetPath:
63     primds=datasetPath.split('/')[1]
64     procds=datasetPath.split('/')[2]
65     tier=datasetPath.split('/')[3]
66     # print " matchProcessedDatasets(%s,%s,%s)"%(primds,tier,procds)
67     datasets=dbsreader.matchProcessedDatasets(primds,tier,procds)
68     else:
69     datasets=dbsreader.matchProcessedDatasets("*","*","*")
70    
71    
72     for dataset in datasets:
73     # //
74     # // Get list of blocks for the dataset and their location
75     #//
76     for datasetpath in dataset.get('PathList'):
77     nevttot=0
78     print "===== dataset %s"%datasetpath
79     blocks=dbsreader.getFileBlocksInfo(datasetpath)
80     for block in blocks:
81     SEList=dbsreader.listFileBlockLocation(block['Name']) # replace that with DLS query
82     print "== File block %s is located at: %s"%(block['Name'],SEList)
83     print "File block name: %s" %block['Name']
84     print "File block status: %s" %block['OpenForWriting']
85     print "Number of files: %s"%block['NumberOfFiles']
86     print "Number of Bytes: %s"%block['BlockSize']
87     print "Number of Events: %s"%block['NumberOfEvents']
88     if full:
89     print "--------- info about files --------"
90     print " Size \t Events \t LFN \t FileStatus "
91     files=dbsreader.listFilesInBlock(block['Name'])
92     for file in files:
93     print "%s %s %s %s"%(file['FileSize'],file['NumberOfEvents'],file['LogicalFileName'],file['Status'])
94     nevttot = nevttot + block['NumberOfEvents']
95    
96     print "\n total events: %s in dataset: %s\n"%(nevttot,datasetpath)
97    
98     if len(dataset.get('PathList'))==0:
99     print "===== Empty dataset yet /%s/%s with tiers %s"%(dataset.get('PrimaryDataset')['Name'],dataset.get('Name'),dataset.get('TierList'))
100    
101    
102    
103