ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/InspectDBS.py
Revision: 1.3
Committed: Fri Apr 1 10:38:54 2011 UTC (14 years, 1 month ago) by fanzago
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, HEAD
Changes since 1.2: +5 -1 lines
Log Message:
Added description field

File Contents

# Content
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 from ProdCommon.DataMgmt.DBS.DBSWriter import DBSWriter
8 from ProdCommon.DataMgmt.DBS.DBSReader import DBSReader
9 from ProdCommon.DataMgmt.DBS.DBSErrors import DBSWriterError, formatEx
10 from DBSAPI.dbsApiException import DbsException
11 import os,getopt
12 from Actor import *
13 import common
14
15
16 class InspectDBS(Actor):
17 def __init__(self, cfg_params):
18 """
19 InspectDBS class:
20
21 - check data publication in a DBS
22 """
23
24 try:
25 self.DBSURL=cfg_params['USER.dbs_url_for_publication']
26 except KeyError:
27 msg = "Warning. You have to specify the url of DBS in the USER.dbs_url_for_publication parameter of crab.cfg or as command line option: \n"
28 msg += "crab -checkPublication -USER.dbs_url_for_publication=<DBS url where data are published> -USER.dataset_to_check=<datasetpath to check>\n"
29 raise CrabException(msg)
30
31 try:
32 self.dataset_to_check=cfg_params['USER.dataset_to_check']
33 except KeyError:
34 msg = "Warning. You have to speficy the dataset you want to check in the USER.dataset_to_check parameter of crab.cfg or as command line option: \n"
35 msg += "crab -checkPublication -USER.dbs_url_for_publication=<DBS url where data are published> -USER.dataset_to_check=<datasetpath to check>\n"
36 raise CrabException(msg)
37
38
39 def checkPublication(self):
40 """
41 check dataset publication in a dbs
42 """
43
44 common.logger.info('--->>> Check data publication: dataset '+self.dataset_to_check+' in DBS url '+ self.DBSURL+'\n')
45 # //
46 # // Get API to DBS
47 #//
48 dbsreader = DBSReader(self.DBSURL)
49 # //
50 # // Get list of datasets
51 #//
52 if len(self.dataset_to_check.split('/')) < 4:
53 msg = "the provided dataset name is not correct"
54 raise CrabException(msg)
55 else:
56 primds=self.dataset_to_check.split('/')[1]
57 procds=self.dataset_to_check.split('/')[2]
58 tier=self.dataset_to_check.split('/')[3]
59 datasets=dbsreader.matchProcessedDatasets(primds,tier,procds)
60 if common.debugLevel:
61 print "PrimaryDataset = ", primds
62 print "ProcessedDataset = ", procds
63 print "DataTier = ", tier
64 print "datasets matching your requirements= ", datasets
65
66 for dataset in datasets:
67 # //
68 # // Get list of blocks for the dataset and their location
69 #//
70 if len(dataset.get('PathList'))==0:
71 print "===== Empty dataset yet /%s/%s with tiers %s"%(dataset.get('PrimaryDataset')['Name'],dataset.get('Name'),dataset.get('TierList'))
72 else:
73 for datasetpath in dataset.get('PathList'):
74 nevttot=0
75 print "=== dataset %s"%datasetpath
76 ### FEDE #######
77 if dataset['Description'] != None:
78 print "=== dataset description = ", dataset['Description']
79 ################
80 blocks=dbsreader.getFileBlocksInfo(datasetpath)
81 for block in blocks:
82 SEList=dbsreader.listFileBlockLocation(block['Name']) # replace that with DLS query
83 print "===== File block name: %s" %block['Name']
84 print " File block located at: ", SEList
85 print " File block status: %s" %block['OpenForWriting']
86 print " Number of files: %s"%block['NumberOfFiles']
87 print " Number of Bytes: %s"%block['BlockSize']
88 print " Number of Events: %s"%block['NumberOfEvents']
89 if common.debugLevel:
90 print "--------- info about files --------"
91 print " Size \t Events \t LFN \t FileStatus "
92 files=dbsreader.listFilesInBlock(block['Name'])
93 for file in files:
94 print "%s %s %s %s"%(file['FileSize'],file['NumberOfEvents'],file['LogicalFileName'],file['Status'])
95 nevttot = nevttot + block['NumberOfEvents']
96 print "\n total events: %s in dataset: %s\n"%(nevttot,datasetpath)
97 if not common.debugLevel:
98 common.logger.info('You can obtain more info about files of the dataset using: crab -checkPublication -USER.dataset_to_check='+self.dataset_to_check+' -USER.dbs_url_for_publication='+self.DBSURL+' -debug')
99
100 def run(self):
101 """
102 parse of all xml file on res dir and creation of distionary
103 """
104 self.checkPublication()