ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/PhEDExDatasvcInfo.py
(Generate patch)

Comparing COMP/CRAB/python/PhEDExDatasvcInfo.py (file contents):
Revision 1.22 by spiga, Tue Mar 31 23:43:22 2009 UTC vs.
Revision 1.26.2.3 by spiga, Sat Sep 19 11:15:57 2009 UTC

# Line 2 | Line 2 | from Actor import *
2   import urllib
3   from xml.dom.minidom import parse
4   from crab_exceptions import *
5 from crab_logger import Logger
5   from WorkSpace import *
6   from urlparse import urlparse
7   from LFNBaseName import *
8  
9   class PhEDExDatasvcInfo:
10 <    def __init__( self , cfg_params ):
10 >    def __init__( self , cfg_params=None, config=None ):
11  
12          ## PhEDEx Data Service URL
13 <        url="https://cmsweb.cern.ch/phedex/datasvc/xml/prod"
15 <        self.datasvc_url = cfg_params.get("USER.datasvc_url",url)
13 >        self.datasvc_url="https://cmsweb.cern.ch/phedex/datasvc/xml/prod"
14  
15          self.FacOps_savannah = 'https://savannah.cern.ch/support/?func=additem&group=cmscompinfrasup'
16 <        stage_out_faq='https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabFaq#How_to_store_output_with_CRAB_2'
16 >        stage_out_faq='https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabHowTo#Stageout_and_publication'
17          self.dataPub_faq = 'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabForPublication'
18  
19 +        self.usePhedex = True
20 +        self.sched = common.scheduler.name().upper()
21 +
22 +        if config!=None:
23 +            self.checkConfig(config)  
24 +        else:
25 +            self.checkCfgConfig(cfg_params)  
26 +
27 +        self.protocol = self.srm_version
28 +
29 +
30 +    def checkConfig(self,config):
31 +        """
32 +        """
33 +        self.srm_version = config.get("srm_version",'srmv2')
34 +        self.node = config.get('storage_element',None)
35 +        self.lfn='/store/'
36 +
37 +    def checkCfgConfig(self,cfg_params):
38 +        """
39 +        """
40 +        self.datasvc_url = cfg_params.get("USER.datasvc_url",self.datasvc_url)
41          self.srm_version = cfg_params.get("USER.srm_version",'srmv2')
42          self.node = cfg_params.get('USER.storage_element',None)
23        
43  
25
26        self.user_lfn = cfg_params.get("USER.lfn",'')
44          self.publish_data = cfg_params.get("USER.publish_data",0)
45          self.usenamespace = cfg_params.get("USER.usenamespace",0)
46          self.user_remote_dir = cfg_params.get("USER.user_remote_dir",'')
47          if self.user_remote_dir:
48              if ( self.user_remote_dir[-1] != '/' ) : self.user_remote_dir = self.user_remote_dir + '/'
32        if self.user_lfn:    
33            msg  = 'Warning: lfn has been deprecated, CRAB will ignore it.\n'
34            msg += '\t Please use only user_remote_dir removing lfn from your crab.cfg\n'
35            msg += '\t For further information please visit : \n\t%s'%stage_out_faq
36            common.logger.message(msg)
49            
50          self.datasetpath = cfg_params.get("CMSSW.datasetpath")
51          self.publish_data_name = cfg_params.get('USER.publish_data_name','')
# Line 44 | Line 56 | class PhEDExDatasvcInfo:
56              if ( self.user_se_path[-1] != '/' ) : self.user_se_path = self.user_se_path + '/'
57                                                      
58          #check if using "private" Storage
47        self.usePhedex = True
59          if not self.node :
60              msg = 'Please specify the storage_element name in your crab.cfg section [USER].\n'
61              msg +='\tFor further information please visit : %s'%stage_out_faq
# Line 56 | Line 67 | class PhEDExDatasvcInfo:
67              msg += '\t must specify both user_remote_dir and storage_path in the crab.cfg section [USER].\n '
68              msg += '\t For further information please visit : \n\t%s'%stage_out_faq
69              raise CrabException(msg)
59        self.sched = common.scheduler.name().upper()
60        self.protocol = self.srm_version
70  
71          self.forced_path = '/store/user/'
72          if self.sched in ['CAF','LSF']:
# Line 77 | Line 86 | class PhEDExDatasvcInfo:
86  
87          #extract the PFN for the given node,LFN,protocol
88          endpoint = self.getStageoutPFN()
89 +        ### FEDE added a check for the final /
90 +        if ( endpoint[-1] != '/' ) : endpoint = endpoint + '/'
91 +        ######################################
92    
93          #extract SE name an SE_PATH (needed for publication)
94          SE, SE_PATH, User = self.splitEndpoint(endpoint)
# Line 138 | Line 150 | class PhEDExDatasvcInfo:
150              raise CrabException(msg)
151          if self.publish_data_name == '' and int(self.usenamespace) == 1:
152             self.publish_data_name = "DefaultDataset"
153 <        if int(self.publish_data) == 1 or int(self.usenamespace) == 1:
153 >        if int(self.publish_data) == 1:
154 >            if self.sched in ['CAF']: l_User=True
155 >            primaryDataset = self.computePrimaryDataset()
156 >            ### added the case lfn = LFNBase(self.forced_path, primaryDataset, self.publish_data_name, publish=True)
157 >            ### for the publication in order to be able to check the lfn length  
158 >            lfn = LFNBase(self.forced_path, primaryDataset, self.publish_data_name, publish=True)  + '/${PSETHASH}/'    
159 >        elif int(self.usenamespace) == 1:
160              if self.sched in ['CAF']: l_User=True
161              primaryDataset = self.computePrimaryDataset()
162              lfn = LFNBase(self.forced_path, primaryDataset, self.publish_data_name)  + '/${PSETHASH}/'    
# Line 167 | Line 185 | class PhEDExDatasvcInfo:
185          params = {'node' : self.node , 'lfn': self.lfn , 'protocol': self.protocol}
186          params = urllib.urlencode(params)
187          datasvc_lfn2pfn="%s/lfn2pfn"%self.datasvc_url
170        urlresults = urllib.urlopen(datasvc_lfn2pfn, params)
188          try:
189 +            urlresults = urllib.urlopen(datasvc_lfn2pfn, params)
190              urlresults = parse(urlresults)
191 +        except IOError:
192 +            msg="Unable to access PhEDEx Data Service at %s"%datasvc_lfn2pfn
193 +            raise CrabException(msg)
194          except:
195              urlresults = None
196  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines