Exemplo n.º 1
0
    def publish(self, **kwargs):
        repo_id = kwargs['repo-id']
        foreground = not kwargs['bg']

        self.context.prompt.render_title(_('Publishing Repository [%(r)s]') % {'r' : repo_id})

        # If a publish is taking place, display it's progress instead. Again, we
        # benefit from the fact that there is only one distributor per repo and
        # if that changes in the future we'll need to rethink this.
        existing_publish_tasks = self.context.server.tasks.get_repo_publish_tasks(repo_id).response_body
        task_id = tasks.relevant_existing_task_id(existing_publish_tasks)

        if task_id is not None:
            msg = _('A publish task is already in progress for this repository. ')
            if foreground:
                msg += _('Its progress will be tracked below.')
            self.context.prompt.render_paragraph(msg)

        else:
            # Trigger the publish call. Eventually the None in the call should
            # be replaced with override options read in from the CLI.
            response = self.context.server.repo_actions.publish(repo_id, DISTRIBUTOR_ID, None)
            task_id = response.response_body.task_id

        if foreground:
            status.display_status(self.context, task_id=task_id)
        else:
            msg = 'The status of this publish request can be displayed using the status command.'
            self.context.prompt.render_paragraph(_(msg))
Exemplo n.º 2
0
    def sync(self, **kwargs):
        repo_id = kwargs['repo-id']
        foreground = not kwargs['bg']

        self.context.prompt.render_title(_('Synchronizing Repository [%(r)s]') % {'r' : repo_id})

        # See if an existing sync is running for the repo. If it is, resume
        # progress tracking.
        existing_sync_tasks = self.context.server.tasks.get_repo_sync_tasks(repo_id).response_body
        if len(existing_sync_tasks) > 0:
            task_id = tasks.relevant_existing_task_id(existing_sync_tasks)

            msg = _('A sync task is already in progress for this repository. ')
            if foreground:
                msg += _('Its progress will be tracked below.')
            self.context.prompt.render_paragraph(msg)

        else:
            # Trigger the actual sync
            response = self.context.server.repo_actions.sync(repo_id, None)
            sync_task = tasks.sync_task_in_sync_task_group(response.response_body)
            task_id = sync_task.task_id

        if foreground:
            status.display_status(self.context, task_id)
        else:
            msg = 'The status of this sync can be displayed using the status command.'
            self.context.prompt.render_paragraph(_(msg))
Exemplo n.º 3
0
    def status(self, **kwargs):
        repo_id = kwargs['repo-id']
        self.context.prompt.render_title(_('Repository Status [%(r)s]') % {'r' : repo_id})

        # This looks dumb but the task lookup doesn't know if there are no tasks
        # for a repo v. the repo doesn't exist. We call this to let the not found
        # exception bubble if it's not a valid repo.
        self.context.server.repo.repository(repo_id)

        # Load the existing sync tasks
        existing_publish_tasks = self.context.server.tasks.get_repo_publish_tasks(repo_id).response_body
        task_id = tasks.relevant_existing_task_id(existing_publish_tasks)

        if task_id is not None:
            msg = 'A publish task is queued on the server. Its progress will be tracked below.'
            self.context.prompt.render_paragraph(_(msg))
            status.display_status(self.context, task_id=task_id)

        else:
            self.context.prompt.render_paragraph(_('There are no publish tasks currently queued in the server.'))