Exemplo n.º 1
0
    def run_fetch(self, progress=None):
        state = RemoteFetch()
        state.save()
        if self.fetchstate:
            self.fetchstate.delete()
        self.fetchstate = state
        self.save()

        def handle_progress(event, p):
            if event == "compressing-objects":
                state.compressing_objects = p
            elif event == "receiving-objects":
                state.receiving_objects = p
            elif event == "resolving-deltas":
                state.resolving_deltas = p
            state.save()
            messagebroker.send(state.dict, destination="/topic/remote.fetch.progress")
            if progress:
                progress(state)

        ret = self.project.git.fetch(self.name, progress=handle_progress)
        if ret:
            state.status = 1
        else:
            state.status = 2
        state.completed_at = now()
        state.save()
        messagebroker.send(state.dict, destination="/topic/remote.fetch.progress")
        messagebroker.send(state.dict, destination="/topic/remote.fetch.finish")
        if progress:
            progress(state)
Exemplo n.º 2
0
 def handle_progress(event, p):
     if event == "compressing-objects":
         state.compressing_objects = p
     elif event == "receiving-objects":
         state.receiving_objects = p
     elif event == "resolving-deltas":
         state.resolving_deltas = p
     state.save()
     messagebroker.send(state.dict, destination="/topic/remote.fetch.progress")
     if progress:
         progress(state)
Exemplo n.º 3
0
 def queue_fetch(self):
     cmd = {"project": self.project.id, "name": self.name}
     messagebroker.send(cmd, destination="/queue/task.remote.fetch")