Пример #1
0
    def _clean(self):

        self._print(_('= Clean Up ='))

        v1_database = self._database(self.prod_db_name)
        tmp_database = self._database(self.tmp_db_name)

        for upgrade_call, description in CLEAN_UPGRADE_CALLS:
            self._print(_('Cleaning: %(d)s') % {'d': description})
            spinner = ThreadedSpinner(self.prompt)
            spinner.start()

            try:
                report = upgrade_call(v1_database, tmp_database)
            except:
                spinner.stop(clear=True)
                raise

            spinner.stop(clear=True)

            if report is None or report.success is None:
                self._print(
                    _('Clean upgrade script did not indicate the result of the step'
                      ))
                raise InvalidStepReportException()

            if report.success:
                self._print_report_data(_('Messages'), report.messages)
                self._print_report_data(_('Warnings'), report.warnings)
            else:
                self._print_report_data(_('Warnings'), report.warnings)
                self._print_report_data(_('Errors'), report.errors)
                raise StepException(description)

            self.prompt.write('')
Пример #2
0
    def _clean(self):

        self._print(_('= Clean Up ='))

        v1_database = self._database(self.prod_db_name)
        tmp_database = self._database(self.tmp_db_name)

        for upgrade_call, description in CLEAN_UPGRADE_CALLS:
            self._print(_('Cleaning: %(d)s') % {'d' : description})
            spinner = ThreadedSpinner(self.prompt)
            spinner.start()

            try:
                report = upgrade_call(v1_database, tmp_database)
            except:
                spinner.stop(clear=True)
                raise

            spinner.stop(clear=True)

            if report is None or report.success is None:
                self._print(_('Clean upgrade script did not indicate the result of the step'))
                raise InvalidStepReportException()

            if report.success:
                self._print_report_data(_('Messages'), report.messages)
                self._print_report_data(_('Warnings'), report.warnings)
            else:
                self._print_report_data(_('Warnings'), report.warnings)
                self._print_report_data(_('Errors'), report.errors)
                raise StepException(description)

            self.prompt.write('')
Пример #3
0
    def create_threaded_spinner(self):
        """
        Creates a spinner that will continually run in its own thread. Unlike
        the spinner returned from create_spinner, the step iteration is not
        controlled by the caller. Once started, the spinner will continue to
        spin at a regular rate in its own thread. The spinner must be stopped
        before any further calls are made to the prompt.

        :rtype: ThreadedSpinner
        """

        spinner = ThreadedSpinner(
            self, refresh_seconds=.5, in_progress_color=COLOR_IN_PROGRESS,
            completed_color=COLOR_COMPLETED, spin_tag=TAG_THREADED_SPINNER
        )

        return spinner
Пример #4
0
    def _upgrade_files(self):
        """
        Runs all configured upgrade scripts for handling the filesystem.
        """

        self._print(_('= Upgrading Pulp Files ='))

        v1_database = self._database(self.prod_db_name)
        tmp_database = self._database(self.tmp_db_name)

        for upgrade_call, description in self.files_upgrade_calls:
            self._print(_('Upgrading: %(d)s') % {'d': description})
            spinner = ThreadedSpinner(self.prompt)
            spinner.start()

            try:
                report = upgrade_call(v1_database, tmp_database)
            except:
                spinner.stop(clear=True)
                raise

            spinner.stop(clear=True)

            if report is None or report.success is None:
                # This should only happen during development if the script writer
                # didn't properly configure the report and must be fixed before
                # release
                self._print(
                    _('Filesystem upgrade script did not indicate the result of the step'
                      ))
                raise InvalidStepReportException()

            if report.success:
                self._print_report_data(_('Messages'), report.messages)
                self._print_report_data(_('Warnings'), report.warnings)
            else:
                self._print_report_data(_('Warnings'), report.warnings)
                self._print_report_data(_('Errors'), report.errors)
                raise StepException(description)

            self.prompt.write('')
Пример #5
0
    def _upgrade_files(self):
        """
        Runs all configured upgrade scripts for handling the filesystem.
        """

        self._print(_('= Upgrading Pulp Files ='))

        v1_database = self._database(self.prod_db_name)
        tmp_database = self._database(self.tmp_db_name)

        for upgrade_call, description in self.files_upgrade_calls:
            self._print(_('Upgrading: %(d)s') % {'d' : description})
            spinner = ThreadedSpinner(self.prompt)
            spinner.start()

            try:
                report = upgrade_call(v1_database, tmp_database)
            except:
                spinner.stop(clear=True)
                raise

            spinner.stop(clear=True)

            if report is None or report.success is None:
                # This should only happen during development if the script writer
                # didn't properly configure the report and must be fixed before
                # release
                self._print(_('Filesystem upgrade script did not indicate the result of the step'))
                raise InvalidStepReportException()

            if report.success:
                self._print_report_data(_('Messages'), report.messages)
                self._print_report_data(_('Warnings'), report.warnings)
            else:
                self._print_report_data(_('Warnings'), report.warnings)
                self._print_report_data(_('Errors'), report.errors)
                raise StepException(description)

            self.prompt.write('')
Пример #6
0
def threaded_spinner_demo():
    p = Prompt()
    s = ThreadedSpinner(p, refresh_seconds=.1)

    p.write(
        'Starting threaded spinner, spinner should keep moving while this thread sleeps'
    )

    s.start()
    time.sleep(3)  # spinner should keep moving
    s.stop()

    p.write('Threaded spinner stopped')
    p.write('')

    s = ThreadedSpinner(p, refresh_seconds=.1, timeout_seconds=2)

    p.write(
        'Starting threaded spinner, spinner will time out while the execution thread is working'
    )

    s.start()
    time.sleep(3)  # spinner should keep moving
    s.stop()

    p.write('Threaded spinner timed out')
    p.write('')

    s = ThreadedSpinner(p, refresh_seconds=.1)

    p.write('Starting threaded spinner with auto-clear')

    s.start()
    time.sleep(3)  # spinner should keep moving
    s.stop(clear=True)

    p.write('Threaded spinner stopped')
    p.write('')

    s = ThreadedSpinner(p, refresh_seconds=3)

    p.write('Starting threaded spinner reuse test')

    s.start()
    time.sleep(.01)
    s.stop()
    p.write('Stopped 1')

    s.start()
    time.sleep(.01)
    s.stop()
    p.write('Stopped 2')
Пример #7
0
    def _install(self):

        # Backup
        if self.backup_v1_db:
            self._print(_('Backing up the v1 database to %(db)s') % {'db' : self.v1_backup_db_name})

            spinner = ThreadedSpinner(self.prompt)
            spinner.start()
            self._backup_v1()
            spinner.stop()
            spinner.clear()
        else:
            self._print(_('The v1 database will not be backed up'))
            self.prompt.write('')

        # Install
        self._print(_('Installing the v2 Database'))

        spinner = ThreadedSpinner(self.prompt)
        spinner.start()
        self._install_v2()
        spinner.stop()
        spinner.clear()

        self.prompt.write('')

        # Clean Up
        self._print(_('Deleting v2 Temporary Database'))

        spinner = ThreadedSpinner(self.prompt)
        spinner.start()
        self._cleanup()
        spinner.stop()
        spinner.clear()

        self.prompt.write('')
Пример #8
0
    def _install(self):

        # Backup
        if self.backup_v1_db:
            self._print(
                _('Backing up the v1 database to %(db)s') %
                {'db': self.v1_backup_db_name})

            spinner = ThreadedSpinner(self.prompt)
            spinner.start()
            self._backup_v1()
            spinner.stop(clear=True)
        else:
            self._print(_('The v1 database will not be backed up'))
            self.prompt.write('')

        # Install
        self._print(_('Installing the v2 Database'))

        spinner = ThreadedSpinner(self.prompt)
        spinner.start()
        self._install_v2()
        spinner.stop(clear=True)

        self.prompt.write('')

        # Clean Up
        self._print(_('Deleting v2 Temporary Database'))

        spinner = ThreadedSpinner(self.prompt)
        spinner.start()
        self._cleanup()
        spinner.stop(clear=True)

        self.prompt.write('')
Пример #9
0
def threaded_spinner_demo():
    p = Prompt()
    s = ThreadedSpinner(p, refresh_seconds=.1)

    p.write('Starting threaded spinner, spinner should keep moving while this thread sleeps')

    s.start()
    time.sleep(3)  # spinner should keep moving
    s.stop()

    p.write('Threaded spinner stopped')
    p.write('')

    s = ThreadedSpinner(p, refresh_seconds=.1, timeout_seconds=2)

    p.write('Starting threaded spinner, spinner will time out while the execution thread is working')

    s.start()
    time.sleep(3)  # spinner should keep moving
    s.stop()

    p.write('Threaded spinner timed out')
    p.write('')

    s = ThreadedSpinner(p, refresh_seconds=.1)

    p.write('Starting threaded spinner with auto-clear')

    s.start()
    time.sleep(3)  # spinner should keep moving
    s.stop(clear=True)

    p.write('Threaded spinner stopped')
    p.write('')

    s = ThreadedSpinner(p, refresh_seconds=3)

    p.write('Starting threaded spinner reuse test')

    s.start()
    time.sleep(.01)
    s.stop()
    p.write('Stopped 1')

    s.start()
    time.sleep(.01)
    s.stop()
    p.write('Stopped 2')