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

Comparing COMP/CRAB/python/cmscp.py (file contents):
Revision 1.12 by spiga, Thu Oct 9 11:50:20 2008 UTC vs.
Revision 1.13 by spiga, Thu Oct 9 14:10:18 2008 UTC

# Line 89 | Line 89 | class cmscp:
89          which depend on scheduler
90          """
91          # default To be used with "middleware"
92 <        lcgOpt={'srmv1':'-b -D srmv1 --vo cms -t 2400 --verbose',
93 <                'srmv2':'-b -D srmv2 --vo cms -t 2400 --verbose'}
94 <        srmOpt={'srmv1':'-debug=true -report ./srmcp.report -retry_timeout 480000 -retry_num 3 -streams_num=1 ',
95 <                'srmv2':'-debug=true -report ./srmcp.report -retry_timeout 480000 -retry_num 3 -srm_protocol_version 2 '}
92 >        lcgOpt={'srmv1':'-b -D srmv1  -t 2400 --verbose',
93 >                'srmv2':'-b -D srmv2  -t 2400 --verbose'}
94 >        srmOpt={'srmv1':' -report ./srmcp.report -retry_timeout 480000 -retry_num 3 -streams_num=1 ',
95 >                'srmv2':' -report ./srmcp.report -retry_timeout 480000 -retry_num 3 '}
96          rfioOpt=''
97  
98          if middleware.lower() in ['osg','lcg']:
# Line 110 | Line 110 | class cmscp:
110          """
111          Implement the logic for remote stage out
112          """
113        count=0
113          results={}
114          for prot, opt in self.setProtocol( middleware ):
115              if self.debug: print 'Trying stage out with %s utils \n'%prot
# Line 118 | Line 117 | class cmscp:
117              list_retry = []
118              list_existing = []
119              list_ok = []
120 <            for file, dict in copy_results.iteritems():
121 <                er_code = dict['erCode']
123 <                if er_code == '60307': list_retry.append( file )
124 <                elif er_code == '60303': list_existing.append( file )
125 <                else:
126 <                    list_ok.append(file)
127 <                    reason = 'Copy succedeed with %s utils'%prot
128 <                    upDict = self.updateReport(file, er_code, reason)
129 <                    copy_results.update(upDict)
130 <            results.update(copy_results)
131 <            if len(list_ok) != 0:
132 <                msg = 'Copy of %s succedeed with %s utils\n'%(str(list_ok),prot)
133 <                if self.debug : print msg
134 <            if len(list_ok) == len(list_files) :
135 <                break
120 >            if copy_results.keys() == '':
121 >                results.update(copy_results)
122              else:
123 <                if self.debug : print 'Copy of files %s failed using %s...\n'%(str(list_retry)+str(list_existing),prot)
124 <                if len(list_retry): list_files = list_retry
125 <                else: break
126 <            count =+1
123 >                for file, dict in copy_results.iteritems():
124 >                    er_code = dict['erCode']
125 >                    if er_code == '0':
126 >                        list_ok.append(file)
127 >                        reason = 'Copy succedeed with %s utils'%prot
128 >                        upDict = self.updateReport(file, er_code, reason)
129 >                        copy_results.update(upDict)
130 >                    elif er_code == '60303': list_existing.append( file )
131 >                    else: list_retry.append( file )
132 >                results.update(copy_results)
133 >                if len(list_ok) != 0:
134 >                    msg = 'Copy of %s succedeed with %s utils\n'%(str(list_ok),prot)
135 >                    if self.debug : print msg
136 >                if len(list_ok) == len(list_files) :
137 >                    break
138 >                else:
139 >                    if self.debug : print 'Copy of files %s failed using %s...\n'%(str(list_retry)+str(list_existing),prot)
140 >                    if len(list_retry): list_files = list_retry
141 >                    else: break
142  
143          #### TODO Daniele
144          #check is something fails and created related dict
# Line 174 | Line 175 | class cmscp:
175          """
176          if self.debug :
177              print 'copy(): using %s protocol'%protocol
178 <        Source_SE, Destination_SE = self.initializeApi( protocol )
179 <
178 >        try:
179 >            Source_SE, Destination_SE = self.initializeApi( protocol )
180 >        except Exception, ex:
181 >            return self.updateReport('', '-1', str(ex))
182 >            
183          # create remote dir
184          if protocol in ['gridftp','rfio']:
185 <            self.createDir( Destination_SE, protocol )
185 >            try:
186 >                self.createDir( Destination_SE, protocol )
187 >            except Exception, ex:
188 >                return self.updateReport('', '60316', str(ex))
189  
190          ## prepare for real copy  ##
191          try :
# Line 187 | Line 194 | class cmscp:
194          except ProtocolMismatch, ex:
195              msg = str(ex)+'\n'
196              msg += "ERROR : Unable to create SBinterface with %s protocol\n"%protocol
197 <            raise msg
197 >            return self.updateReport('', '-1', str(ex))
198  
199          results = {}
200          ## loop over the complete list of files
201          for filetocopy in list_file:
202              if self.debug : print 'start real copy for %s'%filetocopy
203 <            ErCode, msg = self.checkFileExist( sbi_dest, os.path.basename(filetocopy) )
203 >            try :
204 >                ErCode, msg = self.checkFileExist( sbi_dest, os.path.basename(filetocopy) )
205 >            except Exception, ex:
206 >                return self.updateReport(filetocopy, '-1', str(ex))
207              if ErCode == '0':
208                  ErCode, msg = self.makeCopy( sbi, filetocopy , options )
209              if self.debug : print 'Copy results for %s is %s'%( os.path.basename(filetocopy), ErCode)
# Line 211 | Line 221 | class cmscp:
221              msg = ''
222              if self.debug : msg = str(ex)+'\n'
223              msg += "ERROR : Unable to create interface with %s protocol\n"%protocol
224 <            raise msg
224 >            raise Exception(msg)
225  
226          return interface
227  
# Line 220 | Line 230 | class cmscp:
230          Create remote dir for gsiftp REALLY TEMPORARY
231          this should be transparent at SE API level.
232          """
223        ErCode = '0'
233          msg = ''
234          try:
235              action = SBinterface( Destination_SE )
# Line 231 | Line 240 | class cmscp:
240              if self.debug :
241                  msg += str(ex.detail)+'\n'
242                  msg += str(ex.output)+'\n'
243 <            msg_rep = "ERROR: problem with the directory creation using %s protocol \n"%protocol
235 <            ErCode = '60316'
236 <            res = self.updateReport('', ErCode, msg_rep )
237 <            self.finalReport( res )
238 <            raise msg
243 >            msg += "ERROR: problem with the directory creation using %s protocol \n"%protocol
244          except OperationException, ex:
245              msg = str(ex)
246              if self.debug : msg += str(ex.detail)+'\n'
247 <            print msg
247 >            msg = "ERROR: problem with the directory creation using %s protocol \n"%protocol
248  
249 <        return ErCode, msg
249 >        return msg
250  
251      def checkFileExist( self, sbi, filetocopy ):
252          """
# Line 256 | Line 261 | class cmscp:
261              if self.debug :
262                  msg += str(ex.detail)+'\n'
263                  msg += str(ex.output)+'\n'
264 <            msg +='problems checkig if file already exist'
265 <            raise msg
264 >            msg +='ERROR: problems checkig if file %s already exist'%filetocopy
265 >            raise Exception(msg)
266          except WrongOption, ex:
267              msg = str(ex)
268              if self.debug :
269                  msg += str(ex.detail)+'\n'
270                  msg += str(ex.output)+'\n'
271 <            raise msg
271 >            msg +='ERROR problems checkig if file % already exist'%filetocopy
272 >            raise Exception(msg)
273          if check :    
274              ErCode = '60303'
275              msg = "file %s already exist"%filetocopy
276 <
277 <        return ErCode,msg
276 >          
277 >        return ErCode, msg
278  
279      def makeCopy(self, sbi, filetocopy, option ):
280          """
# Line 302 | Line 308 | class cmscp:
308              if self.debug :
309                  msg += str(ex.detail)+'\n'
310                  msg += str(ex.output)+'\n'
311 <            raise msg
311 >            msg += "Problem copying %s file" % filetocopy
312 >            ErCode = '60307'
313  
314           ## TO BE IMPLEMENTED if NEEDED
315           ## NOTE: SE API Already available

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines