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.35 by fanzago, Fri Dec 4 12:08:21 2009 UTC vs.
Revision 1.45 by spiga, Mon Jan 30 12:16:04 2012 UTC

# Line 5 | Line 5 | from crab_exceptions import *
5   from WorkSpace import *
6   from urlparse import urlparse
7   from LFNBaseName import *
8 + from crab_util import getUserName
9  
10   class PhEDExDatasvcInfo:
11      def __init__( self , cfg_params=None, config=None ):
# Line 50 | Line 51 | class PhEDExDatasvcInfo:
51          self.datasetpath = cfg_params.get("CMSSW.datasetpath")
52          self.publish_data_name = cfg_params.get('USER.publish_data_name','')
53  
54 +        self.pset = cfg_params.get('CMSSW.pset',None)
55 +
56          self.user_port = cfg_params.get("USER.storage_port",'8443')
57          self.user_se_path = cfg_params.get("USER.storage_path",'')
58          if self.user_se_path:
# Line 63 | Line 66 | class PhEDExDatasvcInfo:
66          if (self.node.find('T1_') + self.node.find('T2_')+self.node.find('T3_')) == -3: self.usePhedex = False
67  
68          if not self.usePhedex and ( self.user_remote_dir == '' or self.user_se_path == '' ):
69 <            msg = 'You are asking to stage out without using CMS Storage Name convention. In this case you \n'
70 <            msg += '\t must specify both user_remote_dir and storage_path in the crab.cfg section [USER].\n '
71 <            msg += '\t For further information please visit : \n\t%s'%self.stage_out_faq
69 >            ####### FEDE FOR BUG 73010 ############
70 >            msg =  'Error: task ' + common.work_space._top_dir + ' not correctly created. Please remove it. \n'
71 >            msg += '      You are asking to stage out without using CMS Storage Name convention. In this case you \n'
72 >            msg += '      must specify both user_remote_dir and storage_path in the crab.cfg section [USER].\n'
73 >            msg += '      For further information please visit : \n\t%s'%self.stage_out_faq
74 >            task = common._db.getTask()
75 >            #add = '\n\n'
76 >            #import shutil
77 >            #try:
78 >            #    add += '      Task not correctly created: removing the working_dir ' +  common.work_space._top_dir + ' \n'
79 >            #    shutil.rmtree(common.work_space._top_dir)
80 >            #except OSError:
81 >            #    add += '      Warning: problems removing the working_dir ' + common.work_space._top_dir + ' \n'
82 >            #    add += '      Please remove it by hand'
83 >            #msg += add
84              raise CrabException(msg)
85  
86          self.forced_path = '/store/user/'
87 <        if self.sched in ['CAF','LSF','PBS']:
87 >        if self.sched in ['LSF','PBS']:
88              self.srm_version = 'direct'
89 <            self.SE = {'CAF':'caf.cern.ch', 'LSF':'', 'PBS':''}
75 <            if self.sched == 'CAF': self.forced_path = '/store/caf/user/'
89 >            self.SE = {'LSF':'', 'PBS':''}
90              
91 +        if self.sched == 'CAF':
92 +            #### FEDE TEST FOR XROOTD
93 +            ######### first solution ################
94 +            #eos = cfg_params.get("USER.caf_eos_area", 0)
95 +            #if eos == 0:
96 +            #    self.forced_path = '/store/caf/user/'
97 +            #else:    
98 +            #    self.forced_path = '/store/eos/user'
99 +            #########################################
100 +            ######### second solution ###############
101 +            self.forced_path = cfg_params.get("USER.caf_lfn", '/store/caf/user')
102 +            #########################################
103 +            #print "--->>> FORCING THE FIRST PART OF LFN WITH ", self.forced_path
104 +            self.SE = {'CAF':'caf.cern.ch'}
105 +            self.srm_version = 'stageout'
106 +            #print "--->>> query with 'stageout' "
107 +            #########################################
108 +
109          if not self.usePhedex:
110              self.forced_path = self.user_remote_dir
111          return
# Line 91 | Line 123 | class PhEDExDatasvcInfo:
123          #extract SE name an SE_PATH (needed for publication)
124          SE, SE_PATH, User = self.splitEndpoint(endpoint)
125  
126 +        #### FEDE FOR XROOTD #####
127 +        #print "in getEndpoint di PhEDExDatasvcInfo.py: "
128 +        #print "    SE = ", SE
129 +        #print "    SE_PATH = ", SE_PATH
130 +        #print "    User = ", User
131 +        #print "    endpoint = ", endpoint
132 +        ##############################
133 +
134          return endpoint, self.lfn , SE, SE_PATH, User        
135        
136      def splitEndpoint(self, endpoint):
# Line 99 | Line 139 | class PhEDExDatasvcInfo:
139          '''
140          SE = ''
141          SE_PATH = ''
142 <        USER = ''
142 >        USER = getUserName()
143          if self.usePhedex:
144 <            if self.protocol == 'direct':
145 <                query=endpoint
106 <                SE_PATH = endpoint
144 >            ### FEDE PER TEST WITH XROOTD
145 >            if (self.protocol == 'direct' or self.protocol == 'stageout'):
146                  SE = self.SE[self.sched]
147 +                SE_PATH = endpoint
148 +                #############################  
149 +                #print "    SE_PATH = ", SE_PATH
150              else:
151                  url = 'http://'+endpoint.split('://')[1]
110                # python > 2.4
111                # SE = urlparse(url).hostname
152                  scheme, host, path, params, query, fragment = urlparse(url)
113             #   SE = host.split(':')[0]
153                  SE = self.getAuthoritativeSE()
154                  SE_PATH = endpoint.split(host)[1]
116            USER = (query.split('user')[1]).split('/')[1]
155          else:
118            #### to test #####
119           # url = 'http://'+endpoint.split('://')[1]
120           # scheme, host, path, params, query, fragment = urlparse(url)
121           # SE = host.split(':')[0]
122           # SE_PATH = endpoint.split(host)[1]
156              SE = self.node
157              SE_PATH = self.user_se_path + self.user_remote_dir
158 <            if self.lfn.find('user'):
126 <                try:
127 <                    USER = (self.lfn.split('user')[1]).split('/')[1]
128 <                except:
129 <                    pass
130 <            if self.lfn.find('group'):
158 >            if self.lfn.find('group') != -1:
159                  try:
160                      USER = (self.lfn.split('group')[1]).split('/')[1]
161                  except:
162                      pass
163          return SE, SE_PATH, USER
136  
164  
165      def getLFN(self):
166          """
# Line 167 | Line 194 | class PhEDExDatasvcInfo:
194          else:
195              if self.sched in ['CAF','LSF']: l_User=True
196              lfn = LFNBase(self.forced_path,self.user_remote_dir)
197 +
198 +        if lfn.find('${PSETHASH}')>1:
199 +            psethash = runCommand('edmConfigHash < %s| tail -1'%self.pset)
200 +            lfn = string.replace(lfn,'${PSETHASH}',string.strip(psethash))
201          if ( lfn[-1] != '/' ) : lfn = lfn + '/'
202 +
203          return lfn
204  
205      def computePrimaryDataset(self):
# Line 239 | Line 271 | class PhEDExDatasvcInfo:
271              params = {'node' : self.node , 'lfn': self.lfn , 'protocol': self.protocol}
272              datasvc_lfn2pfn="%s/lfn2pfn"%self.datasvc_url
273              fullurl="%s/lfn2pfn?node=%s&lfn=%s&protocol=%s"%(self.datasvc_url,self.node,self.lfn,self.protocol)
274 +            #print "--->>> fullurl = ", fullurl
275              domlfn2pfn = self.domPhedex(params,datasvc_lfn2pfn)
276              if not domlfn2pfn :
277                  msg="Unable to get info from %s"%fullurl

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines