def stop_execution_gently( self, listeners=[], server_to_push=None): # TODO : Refactor, only for ServerListener "Asks listeners to stop the task execution gently if the execution was aborted by user" listener = MultiListener(listeners) listener.listen_end_task_gently(self.name) if server_to_push: server_to_push.update_static_html_files()
def do_subtasks(self, listeners=[NullResultListener()], server_to_push=None, verbose=False): "Executes all subtasks and sends results" listener = MultiListener(listeners) all_ok = True failed_subtasks = [] listener.listen_task_info(self) listener.listen_begin_task(self.name, self.changes) if self.sandboxes: sub_task_name = "Update Sandbox" listener.listen_begin_subtask(sub_task_name) for sandbox in self.sandboxes: fake_command = "Change log for %s" % sandbox.location() listener.listen_begin_command(fake_command) output = ''.join([ ":: %s - %s\n%s\n\n" % (revision, author, message) for revision, author, message in sandbox.guilty() ]) listener.listen_end_command(fake_command, True, '', output, {}) for sandbox in self.sandboxes: fake_command = "Updating %s, %s -> %s" % ( sandbox.location(), sandbox.state(), sandbox.remoteState(), ) listener.listen_begin_command(fake_command) sandbox.update() listener.listen_end_command(fake_command, True, '', '', {}) listener.listen_end_subtask(sub_task_name) for subtask in self.subtasks: subtask_ok = subtask.do_subtask(listener, server_to_push, verbose=verbose) all_ok = all_ok and subtask_ok if not subtask_ok and subtask.is_mandatory( ): # if it is a failing mandatory task, force the end of repository break if not subtask_ok: failed_subtasks.append(subtask.name) # TODO if server_to_push: server_to_push.update_static_html_files() listener.listen_end_task(self.name, all_ok) if server_to_push: server_to_push.update_static_html_files() return all_ok
def do_checking_for_new_commits(self, listeners, verbose=False): "Checks if there is a new commit in the version control system" listener = MultiListener(listeners) if not self._has_new_commits(verbose): listener.listen_found_new_commits(False, self.seconds_idle) return False for sandbox in self.sandboxes: for author, revision, msg in sandbox.guilty(): self.changes.append( (os.path.basename(sandbox.sandbox), revision, author)) print os.path.basename(sandbox.sandbox), revision, author listener.listen_found_new_commits(True, self.seconds_idle) return True
def stop_execution_gently(self, listeners=[] ): # TODO : Refactor, only for ServerListener "Asks listeners to stop the task execution gently if the execution was aborted by user" listener = MultiListener(listeners) listener.listen_end_task_gently(self.name)