Esempio n. 1
0
    def test_run(self):
        """Run the DownloadPackagesTask class."""
        callback = Mock()

        dnf_manager = Mock()
        dnf_manager.download_packages.side_effect = self._download_packages

        task = DownloadPackagesTask(dnf_manager)
        task.progress_changed_signal.connect(callback)
        task.run()

        assert task.name == "Download packages"
        dnf_manager.download_packages.assert_called_once_with(task.report_progress)

        callback.assert_has_calls([
            call(0, "Downloading packages"),
            call(0, "Downloaded 0%"),
            call(0, "Downloaded 50%"),
            call(0, "Downloaded 100%"),
        ])
Esempio n. 2
0
    def install(self):
        progress_message(N_('Starting package installation process'))

        # Get the packages configuration and selection data.
        configuration = self.get_packages_configuration()
        selection = self.get_packages_selection()

        # Add the rpm macros to the global transaction environment
        task = SetRPMMacrosTask(configuration)
        task.run()

        try:
            # Resolve packages.
            task = ResolvePackagesTask(self._dnf_manager, selection)
            task.run()
        except NonCriticalInstallationError as e:
            # FIXME: This is a temporary workaround.
            # Allow users to handle the error. If they don't want
            # to continue with the installation, raise a different
            # exception to make sure that we will not run the error
            # handler again.
            if error_handler.cb(e) == ERROR_RAISE:
                raise InstallationError(str(e)) from e

        # Set up the download location.
        task = PrepareDownloadLocationTask(self._dnf_manager)
        task.run()

        # Download the packages.
        task = DownloadPackagesTask(self._dnf_manager)
        task.progress_changed_signal.connect(self._progress_cb)
        task.run()

        # Install the packages.
        task = InstallPackagesTask(self._dnf_manager)
        task.progress_changed_signal.connect(self._progress_cb)
        task.run()

        # Clean up the download location.
        task = CleanUpDownloadLocationTask(self._dnf_manager)
        task.run()