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.33 by spiga, Tue Nov 24 00:13:02 2009 UTC vs.
Revision 1.40 by fanzago, Wed Jul 13 17:08:40 2011 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 13 | Line 14 | class PhEDExDatasvcInfo:
14          self.datasvc_url="https://cmsweb.cern.ch/phedex/datasvc/xml/prod"
15  
16          self.FacOps_savannah = 'https://savannah.cern.ch/support/?func=additem&group=cmscompinfrasup'
17 <        stage_out_faq='https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabHowTo#Stageout_and_publication'
17 >        self.stage_out_faq='https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabHowTo#Stageout_and_publication'
18          self.dataPub_faq = 'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabForPublication'
19  
20          self.usePhedex = True
# Line 58 | Line 59 | class PhEDExDatasvcInfo:
59          #check if using "private" Storage
60          if not self.node :
61              msg = 'Please specify the storage_element name in your crab.cfg section [USER].\n'
62 <            msg +='\tFor further information please visit : %s'%stage_out_faq
62 >            msg +='\tFor further information please visit : %s'%self.stage_out_faq
63              raise CrabException(msg)
64          if (self.node.find('T1_') + self.node.find('T2_')+self.node.find('T3_')) == -3: self.usePhedex = False
65  
66          if not self.usePhedex and ( self.user_remote_dir == '' or self.user_se_path == '' ):
67 <            msg = 'You are asking to stage out without using CMS Storage Name convention. In this case you \n'
67 >            ##### remove
68 >            ####### FEDE FOR BUG 73010 ############
69 >            print "--------->>>> self = ", self
70 >            task = common._db.getTask()
71 >            print "task = ", task
72 >            print "common.work_space = ", common.work_space._top_dir
73 >            print "removing common.work_space"
74 >            add = '\n'
75 >            import shutil
76 >            try:
77 >                shutil.rmtree(common.work_space._top_dir)
78 >            except OSError:
79 >                add += '\t Warning: problems removing the dir ' + common.work_space._top_dir + ' \n'
80 >                add += '\t Please remove it by hand'
81 >            #common.work_space.delete()
82 >
83 >            msg = 'Error: you are asking to stage out without using CMS Storage Name convention. In this case you \n'
84              msg += '\t must specify both user_remote_dir and storage_path in the crab.cfg section [USER].\n '
85 <            msg += '\t For further information please visit : \n\t%s'%stage_out_faq
85 >            msg += '\t Otherwise this task can not be correctly created. \n'
86 >            msg += '\t For further information please visit : \n\t%s'%self.stage_out_faq
87 >            msg += add
88              raise CrabException(msg)
89 +            #########################################
90  
91          self.forced_path = '/store/user/'
92          if self.sched in ['CAF','LSF','PBS']:
# Line 86 | Line 106 | class PhEDExDatasvcInfo:
106  
107          #extract the PFN for the given node,LFN,protocol
108          endpoint = self.getStageoutPFN()
89        ### FEDE added a check for the final /
109          if ( endpoint[-1] != '/' ) : endpoint = endpoint + '/'
91        ######################################
110    
111          #extract SE name an SE_PATH (needed for publication)
112          SE, SE_PATH, User = self.splitEndpoint(endpoint)
# Line 101 | Line 119 | class PhEDExDatasvcInfo:
119          '''
120          SE = ''
121          SE_PATH = ''
122 <        USER = ''
122 >        USER = getUserName()
123          if self.usePhedex:
124              if self.protocol == 'direct':
125                  query=endpoint
# Line 109 | Line 127 | class PhEDExDatasvcInfo:
127                  SE = self.SE[self.sched]
128              else:
129                  url = 'http://'+endpoint.split('://')[1]
112                # python > 2.4
113                # SE = urlparse(url).hostname
130                  scheme, host, path, params, query, fragment = urlparse(url)
115             #   SE = host.split(':')[0]
131                  SE = self.getAuthoritativeSE()
132                  SE_PATH = endpoint.split(host)[1]
118            USER = (query.split('user')[1]).split('/')[1]
133          else:
134 <            #### to test #####
134 >           #### to test #####
135             # url = 'http://'+endpoint.split('://')[1]
136             # scheme, host, path, params, query, fragment = urlparse(url)
137             # SE = host.split(':')[0]
138             # SE_PATH = endpoint.split(host)[1]
139              SE = self.node
140              SE_PATH = self.user_se_path + self.user_remote_dir
141 <            if self.lfn.find('user'):
128 <                try:
129 <                    USER = (self.lfn.split('user')[1]).split('/')[1]
130 <                except:
131 <                    pass
132 <            if self.lfn.find('group'):
141 >            if self.lfn.find('group') != -1:
142                  try:
143                      USER = (self.lfn.split('group')[1]).split('/')[1]
144                  except:
145                      pass
146          return SE, SE_PATH, USER
138  
147  
148      def getLFN(self):
149          """
# Line 169 | Line 177 | class PhEDExDatasvcInfo:
177          else:
178              if self.sched in ['CAF','LSF']: l_User=True
179              lfn = LFNBase(self.forced_path,self.user_remote_dir)
180 +        if ( lfn[-1] != '/' ) : lfn = lfn + '/'
181          return lfn
182  
183      def computePrimaryDataset(self):
# Line 264 | Line 273 | class PhEDExDatasvcInfo:
273              else:
274                  stageoutpfn = 'srm://'+self.node+':'+self.user_port+self.user_se_path+self.lfn
275  
276 +        if ( stageoutpfn[-1] != '/' ) : stageoutpfn = stageoutpfn + '/'
277          return stageoutpfn
278  
279      def getAuthoritativeSE(self):

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines