ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/DBS/Clients/CRABStandalone/DBSInfo.py
Revision: 1.3
Committed: Tue Nov 8 13:40:08 2005 UTC (19 years, 5 months ago) by afanfani
Content type: text/x-python
Branch: MAIN
CVS Tags: before_message_removal
Changes since 1.2: +17 -24 lines
Log Message:
mods to use dbspath instead of dataset-owner pairs

File Contents

# User Rev Content
1 afanfani 1.1 #!/usr/bin/env python
2     import sys, os, string, re
3 afanfani 1.2 sys.path.append('./DBSAPI')
4     import dbsCgiApi
5 afanfani 1.3 import dbsApi
6 afanfani 1.1
7     class DBSError:
8 afanfani 1.3 def __init__(self, dbspath):
9     print '\nERROR accessing DBS for dataset '+dbspath+'\n'
10 afanfani 1.1 pass
11    
12     class DBSInfoError:
13     def __init__(self, url):
14     print '\nERROR accessing DBS url : '+url+'\n'
15     pass
16    
17     ##################################################################################
18     # Class to extract info from DBS
19     ###############################################################################
20    
21     class DBSInfo:
22 afanfani 1.3 def __init__(self, dbspath, dataTiers):
23     self.dbspath=dbspath
24 afanfani 1.1 self.dataTiers = dataTiers
25 afanfani 1.2
26     self.api = dbsCgiApi.DbsCgiApi(cgiUrl="http://cern.ch/cms-dbs/cgi-bin")
27 afanfani 1.3 # self.api.setLogLevel(dbsApi.DBS_LOG_LEVEL_ALL_)
28 afanfani 1.1
29     # ####################################
30     def getDatasetProvenance(self):
31     """
32     query DBS to get provenance
33     """
34 afanfani 1.3 try:
35     datasetParentList = self.api.getDatasetProvenance(self.dbspath,self.dataTiers)
36     except dbsCgiApi.DbsCgiApiException:
37     raise DBSError(self.dbspath)
38     return datasetParentList
39 afanfani 1.1 # ####################################
40     def getDatasetContents(self):
41     """
42     query DBS to get event collections
43     """
44 afanfani 1.3 try:
45     fileBlockList = self.api.getDatasetContents(self.dbspath)
46     except dbsCgiApi.DbsCgiApiException:
47     raise DBSError(self.dbspath)
48 afanfani 1.1 ## get the fileblock and event collections
49     nevtsbyblock= {}
50 afanfani 1.2 for fileBlock in fileBlockList:
51     ## get the event collections for each block
52 afanfani 1.3 print "DBSInfo: --- block: "+fileBlock.getBlockName()
53 afanfani 1.2 eventCollectionList = fileBlock.getEventCollectionList()
54     nevts=0
55     for eventCollection in eventCollectionList:
56     #print "DBSInfo: evc: "+eventCollection.getCollectionName()+" nevts: %i"%eventCollection.getNumberOfEvents()
57     nevts=nevts+eventCollection.getNumberOfEvents()
58     print "DBSInfo: total nevts %i in block %s "%(nevts,fileBlock.getBlockName())
59 afanfani 1.3 #common.logger.debug(6,"DBSInfo: total nevts %i in block %s "%(nevts,fileBlock.getBlockName()))
60 afanfani 1.2 nevtsbyblock[fileBlock.getBlockName()]=nevts
61 afanfani 1.1
62     # returning a map of fileblock-nevts will be enough for now
63     # TODO: in future the EvC collections grouped by fileblock should be returned
64 afanfani 1.2
65 afanfani 1.1 return nevtsbyblock
66