Exemplo n.º 1
0
 def send_log(self, master, worker, task, subtask=None, workunit=None):
     """
     Sends the requested log file
     
     @param worker - id of worker
     @param task - id of task
     @param subtask - task path for subtask, default=None
     @param workunit - id of workunit, default=None
     """
     d, path = task_log_path(task, subtask, workunit, worker)
     try:
         logger.debug('Sending Log: %s' % path)
         log = open(path, 'r')
         text = log.read()
         compressed = zlib.compress(text)
         return compressed
     except IOError:
         logger.debug("Couldn't send log: %s" % path)
Exemplo n.º 2
0
 def delete_log(self, master, worker, task, subtask=None, workunit=None):
     """
     deletes the requested log file
     
     @param worker - id of worker
     @param task - id of task
     @param subtask - task path for subtask, default=None
     @param workunit - id of workunit, default=None
     """
     d, path = task_log_path(task, subtask, workunit, worker)
     logger.debug('Deleting Log: %s' % path)
     # synchronize deletes to ensure directory gets deleted
     with self.delete_lock:
         try:
             # Remove the log and any directories emptied in the process
             os.remove(path)
             os.removedirs(d)
         except os.error:
             pass
Exemplo n.º 3
0
    def receive_log(self, response, worker, task, subtask=None, workunit=None):
        """
        Callback from a successful call to Node.send_log.  Saves the log
        locally, updates state, and deletes the remote log.
        
        @param worker - id of worker sending the log
        @param task - id of task
        @param subtask - task path for subtask, default=None
        @param workunit - id of workunit, default=None
        """
        logger.debug('Receiving Log: %s %s %s' % (task, subtask, workunit))

        if not response:
            logger.debug("Bogus log: %s %s %s" % (task, subtask, workunit))
            return
        log = zlib.decompress(response)

        d, path = task_log_path(task, subtask, workunit)

        try:
            makedirs(d)
        except OSError:
            # Couldn't make our path to our log; give up.
            logger.debug("Couldn't recieve log: %s %s %s"
                % (task, subtask, workunit))
            return
        out = open(path, 'w')
        out.write(log)
        
        # mark log as received
        if workunit:
            item = WorkUnit.objects.get(task_instance__id=task, \
                                        workunit=workunit)
        else:
            item = TaskInstance.objects.get(id=task)
        item.log_retrieved = True
        item.save()

        # delete remote log
        remote = self.workers[worker]
        remote.callRemote('delete_log', task, subtask, workunit)