def _show_changelog(self): self.base.set_working(True) changelog = self.current_package.changelog if changelog: i = 0 for (c_date, c_ver, msg) in changelog: i += 1 self.view.write( "* %s %s" % (datetime.date.fromtimestamp(c_date).isoformat(), c_ver), "changelog-header") for line in msg.split('\n'): self.view.write("%s" % line, "changelog") self.view.write('\n') if i == 5: # only show the last 5 entries break else: self.view.write(_("No changelog information is available")) if self._is_fedora_pkg(): self.view.write(_("\nOnline Changelog:"), "changelog-header", newline=True) url = const.FEDORA_PACKAGES_URL + self._get_name_for_url() \ + "/changelog" self.view.add_url(url, url, newline=True) self.base.set_working(False)
def __init__(self, window, url_handler): Gtk.Box.__init__(self) vbox = Gtk.Box() vbox.set_orientation(Gtk.Orientation.VERTICAL) # PKGINFO_FILTERS = ['desc', 'updinfo', 'changelog', 'files', 'deps'] tip = _("Package Description") rb = self._get_radio_button('dialog-information-symbolic', "desc", tooltip=tip) vbox.add(rb) tip = _("Package Update Information") vbox.add( self._get_radio_button('software-update-available-symbolic', "updinfo", rb, tip)) #tip = _("Package Changelog") #vbox.add(self._get_radio_button( #'bookmark-new-symbolic', "changelog", rb, tip)) tip = _("Package Filelist") vbox.add( self._get_radio_button('drive-multidisk-symbolic', "files", rb, tip)) tip = _("Package Requirements") vbox.add( self._get_radio_button('insert-object-symbolic', "deps", rb, tip)) vbox.set_margin_right(5) self.pack_start(vbox, False, False, 0) sw = Gtk.ScrolledWindow() self.view = yumex.gui.views.PackageInfoView(window, url_handler) sw.add(self.view) self.pack_start(sw, True, True, 0)
def get_updates(self, *args): logger.debug('Checking for updates') try: self.backend.Lock() pkgs = self.backend.GetPackages('updates') rc = len(pkgs) logger.debug('# of updates : %d' % rc) self.backend.Unlock() except: # Get locking errors logger.debug('Error getting the dnfdaemon lock') rc = -1 if rc > 0: if self.mute_count < 1: # Only show the same notification once # until the user closes the notification if rc != self.last_num_updates: logger.debug('notification opened : # updates = %d', rc) notify = Notification(_('New Updates'), _('%s available updates') % rc) notify.connect('notify-action', self.on_notify_action) notify.show() self.last_num_updates = rc 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 rc
def setup_view(self): """ Create models and columns for the Repo TextView """ store = Gtk.ListStore('gboolean', str, str, 'gboolean') self.set_model(store) # Setup Selection Column col = self.create_selection_column_num( 0, tooltip=_("Click here to switch between\n" " none/all/default selected")) col.set_clickable(True) col.connect('clicked', self.on_section_header_clicked) # Setup resent column cell2 = Gtk.CellRendererPixbuf() # gpgcheck cell2.set_property('icon-name', 'dialog-password-symbolic') column2 = Gtk.TreeViewColumn("", cell2) column2.set_cell_data_func(cell2, self.new_pixbuf) column2.set_sizing(Gtk.TreeViewColumnSizing.FIXED) column2.set_fixed_width(20) column2.set_sort_column_id(-1) self.append_column(column2) # Setup reponame & repofile column's self.create_text_column_num(_('Repository'), 1) self.create_text_column_num(_('Name'), 2) self.set_search_column(1) self.set_reorderable(False) return store
def on_TransactionEvent(self, event, data): if event == 'start-run': self.frontend.infobar.show_progress(True) elif event == 'download': self.frontend.infobar.info(_('Downloading packages')) elif event == 'pkg-to-download': self._dnl_packages = data elif event == 'signature-check': # self.frontend.infobar.show_progress(False) self.frontend.infobar.set_progress(0.0) self.frontend.infobar.info(_('Checking package signatures')) self.frontend.infobar.set_progress(1.0) self.frontend.infobar.info_sub('') elif event == 'run-test-transaction': # self.frontend.infobar.info(_('Testing Package Transactions')) # # User don't care pass elif event == 'run-transaction': self.frontend.infobar.show_progress(True) self.frontend.infobar.info(_('Applying changes to the system')) self.frontend.infobar.hide_sublabel() elif event == 'verify': self.frontend.infobar.show_progress(True) self.frontend.infobar.info(_('Verify changes on the system')) #self.frontend.infobar.hide_sublabel() # elif event == '': elif event == 'fail': self.frontend.infobar.show_progress(False) elif event == 'end-run': self.frontend.infobar.show_progress(False) else: logger.debug('TransactionEvent : %s', event)
def __init__(self, window, url_handler): Gtk.Box.__init__(self) vbox = Gtk.Box() vbox.set_orientation(Gtk.Orientation.VERTICAL) # PKGINFO_FILTERS = ['desc', 'updinfo', 'changelog', 'files', 'deps'] tip = _("Package Description") rb = self._get_radio_button('dialog-information-symbolic', "desc", tooltip=tip) vbox.add(rb) tip = _("Package Update Information") vbox.add(self._get_radio_button( 'software-update-available-symbolic', "updinfo", rb, tip)) #tip = _("Package Changelog") #vbox.add(self._get_radio_button( #'bookmark-new-symbolic', "changelog", rb, tip)) tip = _("Package Filelist") vbox.add(self._get_radio_button( 'drive-multidisk-symbolic', "files", rb, tip)) tip = _("Package Requirements") vbox.add(self._get_radio_button('insert-object-symbolic', "deps", rb, tip)) vbox.set_margin_right(5) self.pack_start(vbox, False, False, 0) sw = Gtk.ScrolledWindow() self.view = yumex.gui.views.PackageInfoView(window, url_handler) sw.add(self.view) self.pack_start(sw, True, True, 0)
def _show_changelog(self): self.base.set_working(True, False) changelog = self.current_package.changelog if changelog: i = 0 for (c_date, c_ver, msg) in changelog: i += 1 self.write( "* %s %s" % (datetime.date.fromtimestamp(c_date).isoformat(), c_ver), "changelog-header") for line in msg.split('\n'): self.write("%s" % line, "changelog") self.write('\n') if i == 5: # only show the last 5 entries break else: self.write(_("No changelog information is available")) if self._is_fedora_pkg(): self.write(_("\nOnline Changelog:"), "changelog-header", newline=True) url = const.FEDORA_PACKAGES_URL + self._get_name_for_url() \ + "/changelog" self.add_url(url, url, newline=True) self.base.set_working(False, False)
def on_TransactionEvent(self, event, data): if event == 'start-run': self.frontend.infobar.show_progress(True) elif event == 'download': self.frontend.infobar.info(_('Downloading packages')) elif event == 'pkg-to-download': self._dnl_packages = data elif event == 'signature-check': # self.frontend.infobar.show_progress(False) self.frontend.infobar.set_progress(0.0) self.frontend.infobar.info(_('Checking package signatures')) self.frontend.infobar.set_progress(1.0) self.frontend.infobar.info_sub('') elif event == 'run-test-transaction': # self.frontend.infobar.info(_('Testing Package Transactions')) # # User don't care pass elif event == 'run-transaction': self.frontend.infobar.show_progress(True) self.frontend.infobar.info(_('Applying changes to the system')) self.frontend.infobar.hide_sublabel() elif event == 'verify': self.frontend.infobar.show_progress(True) self.frontend.infobar.info(_('Verify changes on the system')) #self.frontend.infobar.hide_sublabel() # elif event == '': elif event == 'fail': self.frontend.infobar.show_progress(False) elif event == 'end-run': self.frontend.infobar.show_progress(False) else: logger.debug('TransactionEvent : %s' % event)
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'), _('%s available updates') % 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
def get_root_backend(self): """Get the current root backend. if it is not setup yet, the create it if it is not locked, then lock it """ if self._root_backend is None: self._root_backend = yumex.dnf_backend.DnfRootBackend(self) if self._root_locked is False: logger.debug('Lock the DNF root daemon') locked, msg = self._root_backend.setup() if locked: self._root_locked = True if self._check_cache_expired('system'): self.reset_cache() else: logger.critical("can't get root backend lock") if msg == 'not-authorized': # user canceled the polkit dialog errmsg = _('DNF root backend was not authorized.\n' 'Yum Extender will exit') # DNF is locked by another process elif msg == 'locked-by-other': errmsg = _('DNF is locked by another process.\n\n' 'Yum Extender will exit') self.error_dialog.show(errmsg) # close down and exit yum extender #self.status.SetWorking(False) # reset working state #self.status.SetYumexIsRunning(self.pid, False) sys.exit(1) return self._root_backend
def __init__(self, summary, body): GObject.GObject.__init__(self) Notify.init('Yum Extender') icon = "yumex-dnf" self.__notification = Notify.Notification.new(summary, body, icon) self.__notification.set_timeout(10000) # timeout 10s self.__notification.add_action('later', _('Not Now'), self.__callback) self.__notification.add_action('show', _('Show Updates'), self.__callback) self.__notification.connect('closed', self.__on_closed)
def __init__(self, summary, body): GObject.GObject.__init__(self) Notify.init('Yum Extender') icon = "yumex-dnf" self.notification = Notify.Notification.new(summary, body, icon) self.notification.set_timeout(10000) # timeout 10s self.notification.add_action('later', _('Not Now'), self.callback) self.notification.add_action('show', _('Show Updates'), self.callback) self.notification.connect('closed', self.on_closed)
def __init__(self): ''' @param widget: ''' SelectionView.__init__(self) self.headers = [_('Repository'), _('Filename')] self.store = self.setup_view() self.state = 'normal' self._last_selected = []
def reset_cache(self): logger.debug('Refresh system cache') self.set_working(True, True) self.infobar.info(_('Refreshing Repository Metadata')) rc = self._root_backend.ExpireCache() self.set_working(False) if rc: self._set_cache_refreshed('system') else: dialogs.show_information( self, _('Could not refresh the DNF cache (root)'))
def _build_from_queue(self): """Populate transaction from queue and resolve deps.""" # switch to queue view if self.queue_view.queue.total() == 0: raise misc.QueueEmptyError self.content.select_page('actions') self._populate_transaction() self.infobar.info(_('Searching for dependencies')) rc, result = self.backend.BuildTransaction() self.infobar.info(_('Dependencies resolved')) if not rc: raise misc.TransactionSolveError(result) return result
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()
def _write_update_info(self, upd_info): head = "" head += ("%14s " % _("Release")) + ": %(id)s\n" head += ("%14s " % _("Type")) + ": " head += const.ADVISORY_TYPES[upd_info['type']] + "\n" #head += ("%14s " % _("Status")) + ": %(status)s\n" head += ("%14s " % _("Issued")) + ": %(updated)s\n" head = head % upd_info #if upd_info['updated'] and upd_info['updated'] != upd_info['issued']: # head += " Updated : %s" % upd_info['updated'] self.write(head) head = "" # Add our bugzilla references if upd_info['references']: bzs = [ r for r in upd_info['references'] if r and r[0] == hawkey.REFERENCE_BUGZILLA ] if len(bzs): self.write('\n') header = "Bugzilla" for bz in bzs: (typ, bug, title, url) = bz bug_msg = '- %s' % title self.write("%14s : " % header, newline=False) self.add_url(bug, url) self.write(bug_msg) header = " " ## Add our CVE references #if upd_info['references']: #cves = [r for r in upd_info['references'] #if r and r['type'] == 'cve'] #if len(cves): #cvelist = "" #header = "CVE" #for cve in cves: #cvelist += "%14s : %s\n" % (header, cve['id']) #header = " " #head += cvelist[:-1].rstrip() + '\n\n' desc = upd_info['description'] head += "\n%14s : %s\n" % (_("Description"), yumex.misc.format_block(desc, 17)) head += "\n" self.write(head)
def setup_view(self, view): ''' Setup the TreeView @param view: the TreeView widget ''' model = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING) view.set_model(model) self.create_text_column(_("Name"), view, 0, size=250) self.create_text_column(_("Arch"), view, 1) self.create_text_column(_("Ver"), view, 2) self.create_text_column(_("Repository"), view, 3, size=100) self.create_text_column(_("Size"), view, 4) return model
def setup_view(self, view): """ Setup the TreeView @param view: the TreeView widget """ model = Gtk.TreeStore( GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING ) view.set_model(model) self.create_text_column(_("Name"), view, 0, size=250) self.create_text_column(_("Arch"), view, 1) self.create_text_column(_("Ver"), view, 2) self.create_text_column(_("Repository"), view, 3, size=100) self.create_text_column(_("Size"), view, 4) return model
def populate(self, pkglist, dnl_size): ''' Populate the TreeView with data @param pkglist: list containing view data ''' model = self.store self.store.clear() total_size = 0 for sub, lvl1 in pkglist: label = "<b>%s</b>" % const.TRANSACTION_RESULT_TYPES[sub] level1 = model.append(None, [label, "", "", "", ""]) for pkgid, size, replaces in lvl1: (n, e, v, r, a, repo_id) = str(pkgid).split(',') level2 = model.append( level1, [n, a, "%s.%s" % (v, r), repo_id, yumex.misc.format_number(size)]) # packages there need to be downloaded if sub in ['install', 'update', 'install-deps', 'update-deps', 'obsoletes']: total_size += size for r in replaces: (n, e, v, r, a, repo_id) = str(r).split(',') model.append(level2, [_("<b>replacing</b> {}").format(n), a, "%s.%s" % (v, r), repo_id, yumex.misc.format_number(size)]) self.base.ui.get_object("result_size").set_text( yumex.misc.format_number(total_size)) self.view.expand_all()
def _show_description(self): tags = self.current_package.pkgtags if tags: self.write(_("Tags: %s\n") % ", ".join(tags), "changelog-header") desc = self.current_package.description self.write(desc) self.write('\n') self.write(_("Links: "), "changelog-header", newline=True) self.write(' ', newline=False) url_hp = self.current_package.URL self.add_url(url_hp, url_hp, newline=True) if self._is_fedora_pkg(): self.write(' ', newline=False) url_fp = const.FEDORA_PACKAGES_URL + self._get_name_for_url() self.add_url(url_fp, url_fp, newline=True) self.base.set_working(False)
def on_filter_changed(self, widget, data): """Handle changes in package filter.""" self.infobar.info(const.PACKAGE_LOAD_MSG[data]) self.set_working(True, True) if self.last_search: # we are searching pkgs = self._filter_search_pkgs(data) else: # normal package filter self.current_filter = self.pkg_filter.current pkgs = self.backend.get_packages(data) if data == 'updates': if CONFIG.session.newest_only: pkgs = self.backend.get_packages(data) else: pkgs = self.backend.get_packages('updates_all') obs_pkgs = self.backend.get_packages('obsoletes') pkgs.extend(obs_pkgs) else: pkgs = self.backend.get_packages(data) #self.status.SetUpdateCount(len(pkgs)) self.info.set_package(None) self.infobar.info(_('Adding packages to view')) self.package_view.populate(pkgs) self.set_working(False) self.infobar.hide() if data == 'updates': self.package_view.set_header_click(True) else: self.package_view.set_header_click(False)
def populate(self, pkglist, dnl_size): """ Populate the TreeView with data @param pkglist: list containing view data """ model = self.store self.store.clear() total_size = 0 for sub, lvl1 in pkglist: label = "<b>%s</b>" % const.TRANSACTION_RESULT_TYPES[sub] level1 = model.append(None, [label, "", "", "", ""]) for id, size, replaces in lvl1: (n, e, v, r, a, repo_id) = str(id).split(",") level2 = model.append(level1, [n, a, "%s.%s" % (v, r), repo_id, yumex.misc.format_number(size)]) # packages there need to be downloaded if sub in ["install", "update", "install-deps", "update-deps", "obsoletes"]: total_size += size for r in replaces: (n, e, v, r, a, repo_id) = str(r).split(",") model.append( level2, [ _("<b>replacing</b> {}").format(n), a, "%s.%s" % (v, r), repo_id, yumex.misc.format_number(size), ], ) self.base.ui.get_object("result_size").set_text(yumex.misc.format_number(total_size)) self.view.expand_all()
def _write_update_info(self, upd_info): head = "" head += ("%14s " % _("Release")) + ": %(id)s\n" head += ("%14s " % _("Type")) + ": " head += const.ADVISORY_TYPES[upd_info['type']] + "\n" #head += ("%14s " % _("Status")) + ": %(status)s\n" head += ("%14s " % _("Issued")) + ": %(updated)s\n" head = head % upd_info #if upd_info['updated'] and upd_info['updated'] != upd_info['issued']: # head += " Updated : %s" % upd_info['updated'] self.view.write(head) head = "" # Add our bugzilla references if upd_info['references']: bzs = [r for r in upd_info['references'] if r and r[0] == hawkey.REFERENCE_BUGZILLA] if len(bzs): self.view.write('\n') header = "Bugzilla" for bz in bzs: (typ, bug, title, url) = bz bug_msg = '- %s' % title self.view.write("%14s : " % header, newline=False) self.view.add_url(bug, url) self.view.write(bug_msg) header = " " ## Add our CVE references #if upd_info['references']: #cves = [r for r in upd_info['references'] #if r and r['type'] == 'cve'] #if len(cves): #cvelist = "" #header = "CVE" #for cve in cves: #cvelist += "%14s : %s\n" % (header, cve['id']) #header = " " #head += cvelist[:-1].rstrip() + '\n\n' desc = upd_info['description'] head += "\n%14s : %s\n" % (_("Description"), yumex.misc.format_block(desc, 17)) head += "\n" self.view.write(head)
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, _('Error(s) in search for dependencies'), '\n'.join(result)) if app_quit: self.release_root_backend(quit_dnfdaemon=True) self.app.quit()
def _show_description(self): tags = self.current_package.pkgtags if tags: self.view.write(_("Tags: %s\n") % ", ".join(tags), "changelog-header") desc = self.current_package.description self.view.write(desc) self.view.write('\n') self.view.write(_("Links: "), "changelog-header", newline=True) self.view.write(' ', newline=False) url_hp = self.current_package.URL self.view.add_url(url_hp, url_hp, newline=True) if self._is_fedora_pkg(): self.view.write(' ', newline=False) url_fp = const.FEDORA_PACKAGES_URL + self._get_name_for_url() self.view.add_url(url_fp, url_fp, newline=True) self.base.set_working(False)
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, _('Error(s) in search for dependencies'), '\n'.join(result)) if app_quit: self.release_root_backend(quit=True) self.app.quit()
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: dialogs.show_information( self, _("Can't remove protected package(s)"), '\n'.join(check)) 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 dialogs.show_information( self, _('Error(s) in building transaction'), '\n'.join(e.msgs)) self._reset_on_cancel() except misc.TransactionSolveError as e: dialogs.show_information( self, _('Error(s) in search for dependencies'), '\n'.join(e.msgs)) self._reset_on_error()
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
def _setup_model(self): ''' Setup the model and view ''' model = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING) self.set_model(model) cell1 = Gtk.CellRendererText() column1 = Gtk.TreeViewColumn(_("Packages"), cell1, markup=0) column1.set_resizable(True) self.append_column(column1) cell2 = Gtk.CellRendererText() column2 = Gtk.TreeViewColumn(_("Summary"), cell2, text=1) column2.set_resizable(True) self.append_column(column2) model.set_sort_column_id(0, Gtk.SortType.ASCENDING) self.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) return model
def _show_filelist(self): self.base.set_working(True) filelist = self.current_package.filelist if filelist: for fname in sorted(filelist): self.view.write(fname) else: self.view.write(_("No filelist information is available")) self.base.set_working(False)
def _show_filelist(self): self.base.set_working(True, False) filelist = self.current_package.filelist if filelist: for fname in sorted(filelist): self.write(fname) else: self.write(_("No filelist information is available")) self.base.set_working(False, False)
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, _('Downloading error(s)\n'), '\n'.join(result)) self._reset_on_cancel() return elif rc != 0: # other transaction errors dialogs.show_information( self, _('Error in transaction\n'), '\n'.join(result)) self._reset() return
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( _('Downloading %d files (%sB)...') % (num_files, yumex.misc.format_number(num_bytes)))
def setup_view(self): """ Create Notebook list for single page """ model = Gtk.TreeStore(str, int) self.set_model(model) cell1 = Gtk.CellRendererText() column1 = Gtk.TreeViewColumn(_("History (Date/Time)"), cell1, markup=0) column1.set_resizable(False) column1.set_fixed_width(200) self.append_column(column1) model.set_sort_column_id(0, Gtk.SortType.DESCENDING) return model
def setup_view(self): """ Create Notebook list for single page """ model = Gtk.TreeStore(str) self.set_model(model) cell = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("History Packages"), cell, markup=0) column.set_resizable(True) # column1.set_fixed_width(200) self.append_column(column) # model.set_sort_column_id(0, Gtk.SortType.ASCENDING) return model
def populate_list_downgrade(self): pkg_list = self.queue.packages['do'] label = "<b>%s</b>" % P_("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), ""])
def set_progress(self, frac, label=None): if frac >= 0.0 and frac <= 1.0: self._show_infobar() self.progress.show() self.progress.set_fraction(frac) # make sure that the main label is shown, else the progress # looks bad. this normally happens when changlog or filelist info # is needed for a package and it will trigger the yum daemon to # download the need metadata. if not self.label.get_property('visible'): self.info(_("Getting Package Metadata"))
def get_root_backend(self): """Get the current root backend. if it is not setup yet, the create it if it is not locked, then lock it """ if self._root_backend is None: self._root_backend = yumex.dnf_backend.DnfRootBackend(self) if self._root_locked is False: logger.debug('Lock the DNF root daemon') locked, msg = self._root_backend.setup() if locked: self._root_locked = True if self._check_cache_expired('system'): logger.debug('Refresh system cache') self.set_working(True, True) self.infobar.info(_('Refreshing Repository Metadata')) rc = self._root_backend.ExpireCache() self.set_working(False) if rc: self._set_cache_refreshed('system') else: dialogs.show_information( self, _('Could not refresh the DNF cache (root)')) else: logger.critical("can't get root backend lock") if msg == 'not-authorized': # user canceled the polkit dialog errmsg = _( 'DNF root backend was not authorized.\n' 'Yum Extender will exit') # DNF is locked by another process elif msg == 'locked-by-other': errmsg = _( 'DNF is locked by another process.\n\n' 'Yum Extender will exit') dialogs.show_information(self, errmsg) # close down and exit yum extender #self.status.SetWorking(False) # reset working state #self.status.SetYumexIsRunning(self.pid, False) sys.exit(1) return self._root_backend
def _show_updateinfo(self): self.base.set_working(True) updinfo = self.current_package.updateinfo if updinfo: updinfo.reverse() cnt = 0 for info in updinfo: self._write_update_info(info) cnt += 1 # only show max 3 advisories if cnt == 3: break else: self.view.write(_("No update information is available")) if self._is_fedora_pkg(): self.view.write(_("\nFedora Updates:"), "changelog-header", newline=True) url = const.FEDORA_PACKAGES_URL + self._get_name_for_url() \ + "/updates" self.view.add_url(url, url, newline=True) self.base.set_working(False)
def set_progress(self, frac, label=None): if label: self.progress.set_text(label) if frac >= 0.0 and frac <= 1.0: self.infobar.show() self.progress.show() self.progress.set_fraction(frac) # make sure that the main label is shown, else the progres # looks bad. this is normally happen when changlog # or filelist info is needed for at package # and it will trigger the yum daemon to download the need metadata. if not self.label.get_property('visible'): self.info(_("Getting Package Metadata"))
def _setup_model(self): ''' Setup the model and view ''' store = Gtk.ListStore(GObject.TYPE_PYOBJECT, str) self.set_model(store) if self.group_mode: self.create_selection_colunm('selected', click_handler=self.on_section_header_clicked_group, popup_handler=self.on_section_header_button, tooltip=_("Click to install all/remove all")) else: self.create_selection_colunm('selected', click_handler=self.on_section_header_clicked, popup_handler=self.on_section_header_button, tooltip=_("Click to select/deselect all")) # Setup resent column cell2 = Gtk.CellRendererPixbuf() # new cell2.set_property('icon-name', 'list-add-symbolic') column2 = Gtk.TreeViewColumn("", cell2) column2.set_cell_data_func(cell2, self.new_pixbuf) column2.set_sizing(Gtk.TreeViewColumnSizing.FIXED) column2.set_fixed_width(20) column2.set_sort_column_id(-1) self.append_column(column2) column2.set_clickable(True) self.create_text_column(_("Package"), 'name', size=200) self.create_text_column(_("Ver."), 'fullver', size=120) self.create_text_column( _("Arch."), 'arch', size=60, click_handler=self.arch_menu.on_arch_clicked, tooltip=_('click to filter archs')) self.create_text_column(_("Summary"), 'summary', size=400) self.create_text_column(_("Repo."), 'repository', size=90) self.create_text_column(_("Size"), 'sizeM', size=90) self.set_search_column(1) self.set_enable_search(True) # store.set_sort_column_id(1, Gtk.Gtk.SortType.ASCENDING) self.set_reorderable(False) self.set_fixed_height_mode(True) return store
def _show_updateinfo(self): self.base.set_working(True, False) updinfo = self.current_package.updateinfo if updinfo: updinfo.reverse() cnt = 0 for info in updinfo: self._write_update_info(info) cnt += 1 # only show max 3 advisories if cnt == 3: break else: self.write(_("No update information is available")) if self._is_fedora_pkg(): self.write(_("\nFedora Updates:"), "changelog-header", newline=True) url = const.FEDORA_PACKAGES_URL + self._get_name_for_url() \ + "/updates" self.add_url(url, url, newline=True) self.base.set_working(False, False)
def on_history_undo(self, widget): """Handle the undo button on history page.""" tid = self.history_view.get_selected() logger.debug('History Undo : %s', tid) rc, messages = self.backend.HistoryUndo(tid) if rc: self._process_actions(from_queue=False) else: msg = "Can't undo history transaction :\n%s" % \ ("\n".join(messages)) logger.debug(msg) dialogs.show_information(self, _('Error in undo history transaction'), "\n".join(messages))
def on_history_undo(self, widget): """Handle the undo button on history page.""" tid = self.history_view.get_selected() logger.debug('History Undo : %s', tid) rc, messages = self.backend.HistoryUndo(tid) if rc: self.process_actions(from_queue=False) else: msg = "Can't undo history transaction :\n%s" % \ ("\n".join(messages)) logger.debug(msg) dialogs.show_information( self, _('Error in undo history transaction'), "\n".join(messages))
def populate_list_downgrade(self): ''' ''' pkg_list = self.queue.packages['do'] label = "<b>%s</b>" % P_( "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), ""])
def ask_for_gpg_import(window, values): (pkg_id, userid, hexkeyid, keyurl, timestamp) = values pkg_name = pkg_id.split(',')[0] msg = (_(' Do you want to import this GPG key\n' ' needed to verify the %s package?\n\n' ' Key : 0x%s:\n' ' Userid : "%s"\n' ' From : %s') % (pkg_name, hexkeyid, userid, keyurl.replace("file://", ""))) dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, msg) rc = dialog.run() dialog.destroy() return rc == Gtk.ResponseType.YES
def _get_package_popup(self, pkg, path): """ Create a right click menu, for a given package.""" # get available downgrades popup = Gtk.Menu() mi = Gtk.MenuItem(_("Reinstall Package")) mi.connect('activate', self.on_package_reinstall, pkg) popup.add(mi) # Show downgrade menu only if there is any avaliable downgrades do_pkgs = pkg.downgrades if do_pkgs: print(do_pkgs) popup_sub = Gtk.Menu() for do_pkg in do_pkgs: mi = Gtk.MenuItem(str(do_pkg)) mi.set_use_underline(False) mi.connect('button-press-event', self.on_package_downgrade, pkg, do_pkg) popup_sub.add(mi) popup_sub.show_all() mi = Gtk.MenuItem(_("Downgrade Package")) mi.set_submenu(popup_sub) popup.add(mi) popup.show_all() return popup
def ask_for_gpg_import(window, values): (pkg_id, userid, hexkeyid, keyurl, timestamp) = values pkg_name = pkg_id.split(",")[0] msg = _( " Do you want to import this GPG key\n" " needed to verify the %s package?\n\n" " Key : 0x%s:\n" ' Userid : "%s"\n' " From : %s" ) % (pkg_name, hexkeyid, userid, keyurl.replace("file://", "")) dialog = Gtk.MessageDialog(window, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, msg) rc = dialog.run() dialog.destroy() return rc == Gtk.ResponseType.YES
def __init__(self, frontend): yumex.backend.Backend.__init__(self, frontend, filters=True) dnfdaemon.client.Client.__init__(self) self._gpg_confirm = None self.dnl_progress = None self._files_to_download = 0 self._files_downloaded = 0 if self.running_api_version == const.NEEDED_DAEMON_API: logger.debug('dnfdaemon api version (%d)', self.running_api_version) else: raise dnfdaemon.client.APIVersionError( _('dnfdaemon api version : %d' "\ndon't match" '\nneeded api version : %d') % (self.running_api_version, const.NEEDED_DAEMON_API))
def _setup_model(self): ''' Setup the model and view ''' store = Gtk.ListStore(GObject.TYPE_PYOBJECT, str) self.set_model(store) if self.group_mode: self.create_selection_colunm( 'selected', click_handler=self.on_section_header_clicked_group, popup_handler=self.on_section_header_button, tooltip=_("Click to install all/remove all")) else: self.create_selection_colunm( 'selected', click_handler=self.on_section_header_clicked, popup_handler=self.on_section_header_button, tooltip=_("Click to select/deselect all")) # Setup resent column cell2 = Gtk.CellRendererPixbuf() # new cell2.set_property('icon-name', 'list-add-symbolic') column2 = Gtk.TreeViewColumn("", cell2) column2.set_cell_data_func(cell2, self.new_pixbuf) column2.set_sizing(Gtk.TreeViewColumnSizing.FIXED) column2.set_fixed_width(20) column2.set_sort_column_id(-1) self.append_column(column2) column2.set_clickable(True) self.create_text_column(_("Package"), 'name', size=200) self.create_text_column(_("Ver."), 'fullver', size=120) self.create_text_column(_("Arch."), 'arch', size=60) self.create_text_column(_("Summary"), 'summary', size=400) self.create_text_column(_("Repo."), 'repository', size=90) self.create_text_column(_("Size"), 'sizeM', size=90) self.set_search_column(1) self.set_enable_search(True) # store.set_sort_column_id(1, Gtk.Gtk.SortType.ASCENDING) self.set_reorderable(False) self.set_fixed_height_mode(True) return store