Beispiel #1
0
 def removeJob(self, id):
     with self.myJobsLock:
         if not id in self.myJobs.keys():
             raise Exception('Key not in jobs!')
         
         if self.myJobs[id].status in (STATUS_RUNNING, STATUS_DOWNLOADING):
             raise Exception('Stop job or wait until it finish')
         
         poz = 0
         for job in gc.conf.jobs:
             if job.id == id:
                 break
             poz += 1
             
         del gc.conf.jobs[poz]
                 
         gc.writeConfig()        
         del self.myJobs[id]
         
         import shutil
         
         try:
             shutil.rmtree('jobs%s%s' % (os.sep, int(id)))
         except:
             pass
Beispiel #2
0
 def jobStatusChanged(self, job):
     if callable(self.statusChangeCallback):
         self.statusChangeCallback(job)
         
     if job.status == STATUS_FINISHED:
         i = 0
         
         #forget about it
         for j in gc.conf.jobs:
             if j.id == job._id:
                 del gc.conf.jobs[i]
                 break
             i += 1
         gc.writeConfig()
Beispiel #3
0
 def addJob(self, id, clientUrl, realtime):
     with self.myJobsLock:
         if id in self.myJobs.keys():
             raise Exception('Key already in jobs!')
                         
         newj = gc.conf.jobs.add()
         
         newj.id = id
         newj.clientUrl = clientUrl
         newj.status = STATUS_STOPPED
         newj.realtime = realtime
         
         gc.writeConfig()
                     
         self.myJobs[id] = JobWorker(id, clientUrl, realtime, self)
Beispiel #4
0
    def removeJob(self, id):
        self.myJobsLock.acquire()
        if not id in self.myJobs.keys():
            raise Exception('Key not in jobs!')

        for job in gc.conf.jobs:
            if job.id == id:
                job = None

        gc.writeConfig()
        del self.myJobs[id]

        import shutil

        shutil.rmtree('jobs%s%s' % (os.sep, int(id)))

        self.myJobsLock.release()
Beispiel #5
0
    def run(self):
        if not self._realtime:
            self.setNice()

        from idlegrid.client.config import GridConfig

        pass_globals = {
            'id': self._id,
            'machineId': GridConfig().conf.machineId
        }

        try:
            exec(compile(open(self._mainFile).read(), "main.py", 'exec'),
                 pass_globals)
        except:
            self._status = STATUS_ERROR
        else:
            self._status = STATUS_FINISHED