Exemplo n.º 1
0
    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        background = kwargs[NAME_BACKGROUND]

        self.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
        task_group_id = tasks.relevant_existing_task_group_id(existing_sync_tasks)

        if task_group_id is not None:
            msg = _("A sync task is already in progress for this repository. ")
            if not background:
                msg += _("Its progress will be tracked below.")
            self.context.prompt.render_paragraph(msg, tag="in-progress")

        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_group_id = sync_task.task_group_id

        if not background:
            status.display_group_status(self.context, self.renderer, task_group_id)
        else:
            msg = _("The status of this sync can be displayed using the status command.")
            self.context.prompt.render_paragraph(msg, "background")
Exemplo n.º 2
0
    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        background = kwargs[NAME_BACKGROUND]

        self.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
        task_group_id = tasks.relevant_existing_task_group_id(
            existing_sync_tasks)

        if task_group_id is not None:
            msg = _('A sync task is already in progress for this repository. ')
            if not background:
                msg += _('Its progress will be tracked below.')
            self.context.prompt.render_paragraph(msg, tag='in-progress')

        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_group_id = sync_task.task_group_id

        if not background:
            status.display_group_status(self.context, self.renderer,
                                        task_group_id)
        else:
            msg = _(
                'The status of this sync can be displayed using the status command.'
            )
            self.context.prompt.render_paragraph(msg, 'background')
Exemplo n.º 3
0
    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        self.prompt.render_title(_('Repository Status [%(r)s]') % {'r' : repo_id})

        # Load the relevant task group
        existing_sync_tasks = self.context.server.tasks.get_repo_publish_tasks(repo_id).response_body
        task_group_id = tasks.relevant_existing_task_group_id(existing_sync_tasks)

        if task_group_id is None:
            msg = _('The repository is not performing any operations')
            self.prompt.render_paragraph(msg, tag='no-tasks')
        else:
            status.display_group_status(self.context, self.renderer, task_group_id)
Exemplo n.º 4
0
    def run(self, **kwargs):
        repo_id = kwargs[options.OPTION_REPO_ID.keyword]
        self.prompt.render_title(
            _('Repository Status [%(r)s]') % {'r': repo_id})

        # Load the relevant task group
        existing_sync_tasks = self.context.server.tasks.get_repo_publish_tasks(
            repo_id).response_body
        task_group_id = tasks.relevant_existing_task_group_id(
            existing_sync_tasks)

        if task_group_id is None:
            msg = _('The repository is not performing any operations')
            self.prompt.render_paragraph(msg, tag='no-tasks')
        else:
            status.display_group_status(self.context, self.renderer,
                                        task_group_id)
Exemplo n.º 5
0
    def test_display_group_status(self, mock_display, mock_get):
        """
        Simple test to make sure the pass through to _display_status is correct.
        """

        # Setup
        task_list = mock.MagicMock()
        mock_get.return_value = mock.MagicMock()
        mock_get.return_value.response_body = task_list

        task_group_id = 'fus'

        # Test
        status.display_group_status(self.context, self.renderer, task_group_id)

        # Verify
        self.assertEqual(1, mock_get.call_count)
        self.assertEqual(task_group_id, mock_get.call_args[0][0])

        self.assertEqual(1, mock_display.call_count)
        self.assertEqual(self.context, mock_display.call_args[0][0])
        self.assertEqual(self.renderer, mock_display.call_args[0][1])
        self.assertEqual(task_list, mock_display.call_args[0][2])
Exemplo n.º 6
0
    def test_display_group_status(self, mock_display, mock_get):
        """
        Simple test to make sure the pass through to _display_status is correct.
        """

        # Setup
        task_list = mock.MagicMock()
        mock_get.return_value = mock.MagicMock()
        mock_get.return_value.response_body = task_list

        task_group_id = 'fus'

        # Test
        status.display_group_status(self.context, self.renderer, task_group_id)

        # Verify
        self.assertEqual(1, mock_get.call_count)
        self.assertEqual(task_group_id, mock_get.call_args[0][0])

        self.assertEqual(1, mock_display.call_count)
        self.assertEqual(self.context, mock_display.call_args[0][0])
        self.assertEqual(self.renderer, mock_display.call_args[0][1])
        self.assertEqual(task_list, mock_display.call_args[0][2])