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

Comparing COMP/CRAB/python/DBinterface.py (file contents):
Revision 1.21 by farinafa, Tue Apr 29 15:20:48 2008 UTC vs.
Revision 1.33 by spiga, Mon Jun 2 08:47:23 2008 UTC

# Line 34 | Line 34 | class DBinterface:
34              raise CrabException('Istantiate DB Session : '+str(e))
35  
36          try:
37 <            common.bossSession.installDB('$CRABPRODCOMMONPYTHON/ProdCommon/BossLite/DbObjects/setupDatabase-sqlite.sql')    
37 >            common.bossSession.bossLiteDB.installDB('$CRABPRODCOMMONPYTHON/ProdCommon/BossLite/DbObjects/setupDatabase-sqlite.sql')
38          except Exception, e :
39              raise CrabException('DB Installation error : '+str(e))
40          return
# Line 177 | Line 177 | class DBinterface:
177          """
178          task = self.getTask(jobs)
179  
180        Jobs = task.getJobs()
180          print "--------------------------"
181 <        for Job in Jobs:
182 <            print "Id: ",Job['id']
181 >        for Job in task.jobs:
182 >            print "Id: ",Job['jobId']
183              print "Dest: ", Job['dlsDestination']
184              print "Output: ", Job['outputFiles']
185              print "Args: ",Job['arguments']
186 +            print "Service: ",Job.runningJob['service']
187              print "--------------------------"
188          return      
189  
# Line 206 | Line 206 | class DBinterface:
206              for job in task.jobs:
207                  toPrint=''
208                  common.bossSession.getRunningInstance(job)
209 <                toPrint = "%-5s %-50s " % (job['id'],job.runningJob['schedulerId'])
209 >                toPrint = "%-5s %-50s " % (job['jobId'],job.runningJob['schedulerId'])
210                  lines.append(toPrint)
211              header+= "%-5s %-50s " % ('Job:','ID' )
212          displayReport(self,header,lines)
# Line 299 | Line 299 | class DBinterface:
299              matched.append(i.runningJob[field])
300          return matched
301  
302 +    def newRunJobs(self,nj='all'):
303 +        """
304 +        Get new running instances
305 +        """  
306 +        task = self.getTask(nj)
307 +
308 +        for job in task.jobs:
309 +            common.bossSession.getNewRunningInstance(job)
310 +            job.runningJob['status'] = 'C'
311 +            job.runningJob['statusScheduler'] = 'Created'
312 +        common.bossSession.updateDB(task)    
313 +        return        
314 +
315      def deserXmlStatus(self, reportList):
316  
317          task = self.getTask()
305
318          for job in task.jobs:
319              if not job.runningJob:
320 <                raise CrabException( "Missing running object for job %s"%str(job['id']) )
320 >                raise CrabException( "Missing running object for job %s"%str(job['jobId']) )
321  
322 <            id = str(job.runningJob['id'])
311 <            # TODO linear search, probably it can be optized with binary search
322 >            id = str(job.runningJob['jobId'])
323              rForJ = None
324 +            nj_list= []
325              for r in reportList:
326                  if r.getAttribute('id') in [ id, 'all']:
327                      rForJ = r
328                      break
329 +            ## Check the submission number and create new running jobs on the client side          
330 +            if int(job.runningJob['submission']) < int(rForJ.getAttribute('resubmit')) + 1:
331 +                nj_list.append(id)
332 +                self.newRunJobs(nj_list)
333  
334 +        task_new = self.getTask()
335 +
336 +        for job in task_new.jobs:
337 +            id = str(job.runningJob['jobId'])
338 +            # TODO linear search, probably it can be optized with binary search
339 +            rForJ = None
340 +            for r in reportList:
341 +                if r.getAttribute('id') in [ id, 'all']:
342 +                    rForJ = r
343 +                    break  
344              # Data alignment
345              jobStatus = str(job.runningJob['statusScheduler'])
346 <            if rForJ.getAttribute('status') not in ['Created', 'Submitting'] and \
346 >            if rForJ.getAttribute('statusScheduler') not in ['Created', 'Submitting', 'Unknown'] and \
347                       job.runningJob['statusScheduler'] != 'Cleared':
348                  job.runningJob['statusScheduler'] = str( rForJ.getAttribute('status') )
349                  jobStatus = str(job.runningJob['statusScheduler'])
# Line 332 | Line 358 | class DBinterface:
358              job.runningJob['wrapperReturnCode'] = str( rForJ.getAttribute('job_exit') )
359              job_exit_code = str(job.runningJob['wrapperReturnCode'])
360  
361 <            if str( rForJ.getAttribute('resubmit') ).isdigit():
362 <                job['submissionNumber'] = int(rForJ.getAttribute('resubmit'))
363 <            # TODO cleared='0' field, how should it be handled/mapped in BL? #Fabio
361 >            #if str( rForJ.getAttribute('resubmit') ).isdigit():
362 >            #    job['submissionNumber'] = int(rForJ.getAttribute('resubmit'))
363 >            #    job.runningJob['submission'] =  int(rForJ.getAttribute('resubmit'))
364  
365 <        common.bossSession.updateDB( task )
365 >            # TODO cleared='0' field, how should it be handled/mapped in BL? #Fabio
366  
367 +        common.bossSession.updateDB( task_new )
368          return
369 +
370 +    # FIXME temporary method to verify what kind of submission to perform towards the server
371 +    def checkIfNeverSubmittedBefore(self):
372 +        for j in self.getTask().jobs:
373 +            if j.runningJob['submission'] > 1 or j.runningJob['status'] != 'C' or \
374 +                    j.runningJob['statusScheduler'] != 'Created':
375 +                return False
376 +        return True
377 +
378 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines