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.15 by mcinquil, Tue Apr 15 14:13:07 2008 UTC vs.
Revision 1.28 by farinafa, Tue May 20 16:59:51 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 119 | Line 119 | class DBinterface:
119              parameters['jobId'] =  str(id)
120              parameters['name'] = task['name'] + '_' + 'job' + str(id)
121              job = Job(parameters)
122 <            jobs.append(job)  
122 >            jobs.append(job)
123 >            common.bossSession.getRunningInstance(job)
124 >            job.runningJob['status'] = 'C'
125          task.addJobs(jobs)
126          try:
127              common.bossSession.updateDB( task )
# Line 173 | Line 175 | class DBinterface:
175          """
176           List a complete set of infos for a job/range of jobs  
177          """
178 <        task = self.getTask()
177 <
178 <        njobs = len(jobs)
179 <        lines=[]
180 <        header=''
181 <     #   ##query the DB asking the right infos for runningJobs  TODO  DS
182 <     #   for job in jobs:
183 <     #       ## here the query over runngJobs  
184 <     #       pass
178 >        task = self.getTask(jobs)
179  
180 <
181 <     #   ##Define Header to show and Pass the query results,
182 <     #   ##  header and format to displayReport()   TODO  DS
183 <     #   if njobs == 1: plural = ''
184 <     #   else:          plural = 's'
185 <     #   header += 'Listing %d job%s:\n' % (njobs, plural)
186 <     #   header += ' :\n' % (---) ## TODO DS
187 <
194 <     #   displayReport(header, lines):
180 >        Jobs = task.getJobs()
181 >        print "--------------------------"
182 >        for Job in Jobs:
183 >            print "Id: ",Job['jobId']
184 >            print "Dest: ", Job['dlsDestination']
185 >            print "Output: ", Job['outputFiles']
186 >            print "Args: ",Job['arguments']
187 >            print "--------------------------"
188          return      
189  
190      def serializeTask(self, tmp_task = None):
# Line 213 | 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 234 | Line 227 | class DBinterface:
227          lines=[]
228          task = self.getTask(jobsL)
229          for job in task.jobs:
230 <            lines.append(eval(job[attr]))
230 >            lines.append(job[attr])
231          return lines
232  
233      def queryRunJob(self, attr, jobsL):
# Line 260 | Line 253 | class DBinterface:
253              common.logger.debug(3, "Error loading Jobs By distinct Attr : " +str(traceback.format_exc()))
254              raise CrabException('Error loading Jobs By distinct Attr '+str(e))
255  
256 <        for i in task: distAttr.append(eval(i[attr]))  
256 >        for i in task: distAttr.append(i[attr])  
257          return  distAttr
258  
259      def queryDistJob_Attr(self, attr_1, attr_2, list):
# Line 274 | Line 267 | class DBinterface:
267              common.logger.debug(3, "Error loading Jobs By distinct Attr : " +str(traceback.format_exc()))
268              raise CrabException('Error loading Jobs By distinct Attr '+str(e))
269  
270 <        for i in task: distAttr.append(eval(i[attr_1]))  
270 >        for i in task: distAttr.append(i[attr_1])  
271          return  distAttr
272  
273      def queryAttrJob(self, attr, field):
# Line 303 | Line 296 | class DBinterface:
296              common.logger.debug(3, "Error loading Jobs By Running Attr : " +str(traceback.format_exc()))
297              raise CrabException('Error loading Jobs By Running Attr '+str(e))
298          for i in task:
299 <            matched.append(i[field])
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()
318 +
319 +        for job in task.jobs:
320 +            if not job.runningJob:
321 +                raise CrabException( "Missing running object for job %s"%str(job['jobId']) )
322 +
323 +            id = str(job.runningJob['jobId'])
324 +            # TODO linear search, probably it can be optized with binary search
325 +            rForJ = None
326 +            for r in reportList:
327 +                if r.getAttribute('id') in [ id, 'all']:
328 +                    rForJ = r
329 +                    break
330 +
331 +            # Data alignment
332 +            jobStatus = str(job.runningJob['statusScheduler'])
333 +            if rForJ.getAttribute('status') not in ['Created', 'Submitting', 'Unknown'] and \
334 +                     job.runningJob['statusScheduler'] != 'Cleared':
335 +                job.runningJob['statusScheduler'] = str( rForJ.getAttribute('status') )
336 +                jobStatus = str(job.runningJob['statusScheduler'])
337 +                job.runningJob['status'] = str( rForJ.getAttribute('sched_status') )
338 +
339 +            job.runningJob['destination'] = str( rForJ.getAttribute('site') )
340 +            dest = str(job.runningJob['destination']).split(':')[0]
341 +
342 +            job.runningJob['applicationReturnCode'] = str( rForJ.getAttribute('exe_exit') )
343 +            exe_exit_code = str(job.runningJob['applicationReturnCode'])
344 +
345 +            job.runningJob['wrapperReturnCode'] = str( rForJ.getAttribute('job_exit') )
346 +            job_exit_code = str(job.runningJob['wrapperReturnCode'])
347 +
348 +            #if str( rForJ.getAttribute('resubmit') ).isdigit():
349 +            #    job['submissionNumber'] = int(rForJ.getAttribute('resubmit'))
350 +            #    job.runningJob['submission'] =  int(rForJ.getAttribute('resubmit'))
351 +
352 +            # TODO cleared='0' field, how should it be handled/mapped in BL? #Fabio
353 +
354 +        common.bossSession.updateDB( task )
355 +
356 +        return
357 +
358 +    # FIXME temporary method to verify what kind of submission to perform towards the server
359 +    def checkIfNeverSubmittedBefore(self):
360 +        for j in self.getTask().jobs:
361 +            if j.runningJob['submission'] > 1 or j.runningJob['status'] != 'C':
362 +                return False
363 +        return True
364 +
365 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines