예제 #1
0
    def _process_actions(self, from_queue=True):
        """Process the current actions in the queue.

        - setup the Dnf transaction
        - resolve dependencies
        - ask user for confirmation on result of depsolve
        - run the transaction
        """
        self.set_working(True, True)
        self.infobar.info(_('Preparing system for applying changes'))
        try:
            if from_queue:
                result = self._build_from_queue()
            else:
                result = self._get_transaction()
            self.set_working(False)
            # check for protected packages
            check = self._check_protected(result)
            if check:
                self.error_dialog.show(
                    ngettext("Can't remove protected package:",
                             "Can't remove protected packages:", len(check)) +
                    misc.list_to_string(check, "\n ", ",\n "))
                self._reset_on_cancel()
                return
            # transaction confirmation dialog
            self.transaction_result.populate(result, '')
            ok = self.transaction_result.run()
            if ok:  # Ok pressed
                self._run_transaction()
            else:  # user cancelled transaction
                self._reset_on_cancel()
                return
        except misc.QueueEmptyError:  # Queue is empty
            self.set_working(False)
            dialogs.show_information(self, _('No pending actions in queue'))
            self._reset_on_cancel()
        except misc.TransactionBuildError as e:
            # Error in building transaction
            self.error_dialog.show(
                ngettext('Error in building transaction',
                         'Errors in building transaction', len(e.msgs)) +
                '\n'.join(e.msgs))
            self._reset_on_cancel()
        except misc.TransactionSolveError as e:
            self.error_dialog.show(
                ngettext('Error in search for dependencies',
                         'Errors in search for dependencies', len(e.msgs)) +
                '\n'.join(e.msgs))
            self._reset_on_error()
예제 #2
0
 def __get_updates(self):
     logger.debug('Checking for updates')
     if self.__backend.Lock():
         pkgs = self.__backend.GetPackages('updates')
         update_count = len(pkgs)
         self.__backend.Unlock()
         logger.debug('#Number of updates : %d', update_count)
     else:
         logger.debug('Could not get the dnfdaemon lock')
         update_count = -1
     if update_count > 0:
         if self.__mute_count < 1:
             # Only show the same notification once
             # until the user closes the notification
             if update_count != self.__last_num_updates:
                 logger.debug('notification opened : # updates = %d',
                              update_count)
                 notify = _Notification(
                     _('New Updates'),
                     # Translators: %d is a number of available updates
                     ngettext('%d available update', '%d available updates',
                              update_count) % update_count)
                 notify.connect('notify-action', self.__on_notify_action)
                 notify.show()
                 self.__last_num_updates = update_count
             else:
                 logger.debug('skipping notification (same # of updates)')
         else:
             self.__mute_count -= 1
             logger.debug('skipping notification : mute_count = %s',
                          self.__mute_count)
     self.__update_timestamp.store_current_time()
     self.start_update_timer()  # restart update timer if necessary
     return update_count
예제 #3
0
    def _run_transaction(self):
        """Run the current transaction."""
        self.infobar.info(_('Applying changes to the system'))
        self.set_working(True, True)
        rc, result = self.backend.RunTransaction()
        # This can happen more than once (more gpg keys to be
        # imported)
        while rc == 1:
            # get info about gpgkey to be comfirmed
            values = self.backend._gpg_confirm
            if values:  # There is a gpgkey to be verified
                (pkg_id, userid, hexkeyid, keyurl, timestamp) = values
                logger.debug('GPGKey : %s' % repr(values))
                ok = dialogs.ask_for_gpg_import(self, values)
                if ok:
                    # tell the backend that the gpg key is confirmed
                    self.backend.ConfirmGPGImport(hexkeyid, True)
                    # rerun the transaction
                    # FIXME: It should not be needed to populate
                    # the transaction again
                    self._populate_transaction()
                    rc, result = self.backend.BuildTransaction()
                    rc, result = self.backend.RunTransaction()
                else:
                    break
            else:  # error in signature verification
                dialogs.show_information(
                    self, _('Error checking package signatures\n'),
                    '\n'.join(result))
                break

        if rc == 4:  # Download errors
            dialogs.show_information(
                self,
                ngettext('Downloading error\n', 'Downloading errors\n',
                         len(result)), '\n'.join(result))
            self._reset_on_cancel()
            return
        elif rc != 0:  # other transaction errors
            dialogs.show_information(
                self,
                ngettext('Error in transaction\n', 'Errors in transaction\n',
                         len(result)), '\n'.join(result))
        self._reset()
        return
예제 #4
0
 def populate_list_downgrade(self):
     pkg_list = self.queue.packages['do']
     label = "<b>%s</b>" % ngettext("Package to downgrade",
                                    "Packages to downgrade", len(pkg_list))
     if len(pkg_list) > 0:
         parent = self.store.append(None, [label, ""])
         for pkg in pkg_list:
             item = self.store.append(parent,
                                      [str(pkg.downgrade_po), pkg.summary])
             self.store.append(
                 item, [_("<b>Downgrade to</b> %s ") % str(pkg), ""])
예제 #5
0
 def on_DownloadStart(self, num_files, num_bytes):
     """Starting a new parallel download batch."""
     #values =  (num_files, num_bytes)
     #print('on_DownloadStart : %s' % (repr(values)))
     self._files_to_download = num_files
     self._files_downloaded = 0
     self.frontend.infobar.set_progress(0.0)
     self.frontend.infobar.info_sub(
         # Translators: %d will be replaced with the number of files
         # to download; %s will be replaced with the preformatted
         # number of bytes to download + the prefix (k, M, etc.)
         # Note that 'B' for 'bytes' is already here, it must be preserved.
         ngettext('Downloading %d file (%sB)...',
                  'Downloading %d files (%sB)...', num_files) %
         (num_files, yumex.misc.format_number(num_bytes)))
예제 #6
0
    def _process_actions_installmode(self, action, package, always_yes,
                                     app_quit):
        """Process the pending actions from the command line.

        :param action: action to perform (install/remove)
        :param package: package to work on
        :param always_yes: ask the user or default to yes/ok to all questions
        """
        if action == 'install':
            self.infobar.info(_('Installing package: %s') % package)
            exit_msg = _('%s was installed successfully') % package
            self.infobar.info_sub(package)
            txmbrs = self.backend.Install(package)
            logger.debug('txmbrs: %s' % str(txmbrs))
        elif action == 'remove':
            self.infobar.info(_('Removing package: %s') % package)
            exit_msg = _('%s was removed successfully') % package
            self.infobar.info_sub(package)
            txmbrs = self.backend.Remove(package)
            logger.debug('txmbrs: %s' % str(txmbrs))
        elif action == 'update':
            self.infobar.info(_('Updating all available updates'))
            exit_msg = _('Available updates was applied successfully')
            txmbrs = self.backend.Update('*')
        self.infobar.info(_('Searching for dependencies'))
        rc, result = self.backend.BuildTransaction()
        self.infobar.info(_('Dependencies resolved'))
        if rc:
            self.transaction_result.populate(result, '')
            if not always_yes:
                ok = self.transaction_result.run()
            else:
                ok = True
            if ok:  # Ok pressed
                self.infobar.info(_('Applying changes to the system'))
                self.backend.RunTransaction()
                self.release_root_backend()
                self.hide()
                misc.notify('Yum Extender', exit_msg)
        else:
            dialogs.show_information(
                self,
                ngettext('Error in search for dependencies',
                         'Errors in search for dependencies', len(result)),
                '\n'.join(result))
        if app_quit:
            self.release_root_backend(quit_dnfdaemon=True)
            self.app.quit()
예제 #7
0
 def refresh(self):
     """ Populate view with data from queue """
     self.store.clear()
     pkg_list = self.queue.packages['u'] + self.queue.packages['o']
     label = "<b>%s</b>" % ngettext("Package to update",
                                    "Packages to update", len(pkg_list))
     if len(pkg_list) > 0:
         self.populate_list(label, pkg_list)
     pkg_list = self.queue.packages['i']
     label = "<b>%s</b>" % ngettext("Package to install",
                                    "Packages to install", len(pkg_list))
     if len(pkg_list) > 0:
         self.populate_list(label, pkg_list)
     pkg_list = self.queue.packages['r']
     label = "<b>%s</b>" % ngettext("Package to remove",
                                    "Packages to remove", len(pkg_list))
     if len(pkg_list) > 0:
         self.populate_list(label, pkg_list)
     pkg_list = self.queue.packages['ri']
     label = "<b>%s</b>" % ngettext("Package to reinstall",
                                    "Packages to reinstall", len(pkg_list))
     if len(pkg_list) > 0:
         self.populate_list(label, pkg_list)
     pkg_list = self.queue.packages['li']
     label = "<b>%s</b>" % ngettext("RPM file to install",
                                    "RPM files to install", len(pkg_list))
     if len(pkg_list) > 0:
         self.populate_list(label, pkg_list)
     grps = self.queue.groups['i']
     label = "<b>%s</b>" % ngettext("Group to install", "Groups to install",
                                    len(pkg_list))
     if len(grps) > 0:
         self.populate_group_list(label, grps)
     grps = self.queue.groups['r']
     label = "<b>%s</b>" % ngettext("Group to remove", "Groups to remove",
                                    len(pkg_list))
     if len(grps) > 0:
         self.populate_group_list(label, grps)
     self.populate_list_downgrade()
     self.expand_all()
     self.emit('queue-refresh', self.queue.total())