def __init__(self, datadir=None, logdir=None): DistUpgradeView.__init__(self) self.config = DistUpgradeConfig(".") self._fetchProgress = NonInteractiveFetchProgress() self._installProgress = NonInteractiveInstallProgress(logdir) self._opProgress = apt.progress.base.OpProgress() sys.__excepthook__ = self.excepthook
def confirmChanges(self, summary, changes, demotions, downloadSize, actions=None, removal_bold=True): DistUpgradeView.confirmChanges(self, summary, changes, demotions, downloadSize, actions) logging.debug("toinstall: '%s'" % [p.name for p in self.toInstall]) logging.debug("toupgrade: '%s'" % [p.name for p in self.toUpgrade]) logging.debug("toremove: '%s'" % [p.name for p in self.toRemove]) return True
def confirmChanges(self, summary, changes, demotions, downloadSize, actions=None, removal_bold=True): DistUpgradeView.confirmChanges(self, summary, changes, demotions, downloadSize, actions) print print twrap(summary) print twrap(self.confirmChangesMessage) print " %s %s" % (_("Continue [yN] "), _("Details [d]")), while True: res = sys.stdin.readline() # TRANSLATORS: the "y" is "yes" if res.strip().lower().startswith(_("y")): return True # TRANSLATORS: the "n" is "no" elif res.strip().lower().startswith(_("n")): return False # TRANSLATORS: the "d" is "details" elif res.strip().lower().startswith(_("d")): output = "" if len(self.demotions) > 0: output += "\n" output += twrap(_("No longer supported: %s\n") % " ".join([p.name for p in self.demotions]), subsequent_indent=' ') if len(self.toRemove) > 0: output += "\n" output += twrap(_("Remove: %s\n") % " ".join([p.name for p in self.toRemove]), subsequent_indent=' ') if len(self.toRemoveAuto) > 0: output += twrap( _("Remove (was auto installed) %s") % " ".join([p.name for p in self.toRemoveAuto]), subsequent_indent=' ') output += "\n" if len(self.toInstall) > 0: output += "\n" output += twrap(_("Install: %s\n") % " ".join([p.name for p in self.toInstall]), subsequent_indent=' ') if len(self.toUpgrade) > 0: output += "\n" output += twrap(_("Upgrade: %s\n") % " ".join([p.name for p in self.toUpgrade]), subsequent_indent=' ') self.showInPager(output) print "%s %s" % (_("Continue [yN] "), _("Details [d]")),
def confirmChanges(self, summary, changes, demotions, downloadSize, actions=None, removal_bold=True): DistUpgradeView.confirmChanges(self, summary, changes, demotions, downloadSize, actions) print print twrap(summary) print twrap(self.confirmChangesMessage) print " %s %s" % (_("Continue [yN] "), _("Details [d]")), while True: res = sys.stdin.readline() # TRANSLATORS: the "y" is "yes" if res.strip().lower().startswith(_("y")): return True # TRANSLATORS: the "n" is "no" elif res.strip().lower().startswith(_("n")): return False # TRANSLATORS: the "d" is "details" elif res.strip().lower().startswith(_("d")): output = "" if len(self.demotions) > 0: output += "\n" output += twrap( _("No longer supported: %s\n") % " ".join([p.name for p in self.demotions]), subsequent_indent=' ') if len(self.toRemove) > 0: output += "\n" output += twrap( _("Remove: %s\n") % " ".join([p.name for p in self.toRemove]), subsequent_indent=' ') if len(self.toRemoveAuto) > 0: output += twrap( _("Remove (was auto installed) %s") % " ".join([p.name for p in self.toRemoveAuto]), subsequent_indent=' ') output += "\n" if len(self.toInstall) > 0: output += "\n" output += twrap( _("Install: %s\n") % " ".join([p.name for p in self.toInstall]), subsequent_indent=' ') if len(self.toUpgrade) > 0: output += "\n" output += twrap( _("Upgrade: %s\n") % " ".join([p.name for p in self.toUpgrade]), subsequent_indent=' ') self.showInPager(output) print "%s %s" % (_("Continue [yN] "), _("Details [d]")),
def confirmChanges(self, summary, changes, downloadSize, actions=None): DistUpgradeView.confirmChanges(self, summary, changes, downloadSize, actions) pkgs_remove = len(self.toRemove) pkgs_inst = len(self.toInstall) pkgs_upgrade = len(self.toUpgrade) msg = "" if pkgs_remove > 0: # FIXME: make those two seperate lines to make it clear # that the "%" applies to the result of ngettext msg += gettext.ngettext("%d package is going to be removed.", "%d packages are going to be removed.", pkgs_remove) % pkgs_remove msg += " " if pkgs_inst > 0: msg += gettext.ngettext( "%d new package is going to be " "installed.", "%d new packages are going to be " "installed.", pkgs_inst) % pkgs_inst msg += " " if pkgs_upgrade > 0: msg += gettext.ngettext( "%d package is going to be upgraded.", "%d packages are going to be upgraded.", pkgs_upgrade) % pkgs_upgrade msg += " " if downloadSize > 0: msg += _("\n\nYou have to download a total of %s. ") %\ apt_pkg.SizeToStr(downloadSize) msg += estimatedDownloadTime(downloadSize) msg += "." if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100: msg += "\n\n%s" % _("Fetching and installing the upgrade can take several hours and "\ "cannot be canceled at any time later.") # Show an error if no actions are planned if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: # FIXME: this should go into DistUpgradeController summary = _("Your system is up-to-date") msg = _("There are no upgrades available for your system. " "The upgrade will now be canceled.") self.error(summary, msg) return False return self.askYesNoQuestion(summary, msg)
def confirmChanges(self, summary, changes, downloadSize, actions=None): DistUpgradeView.confirmChanges(self, summary, changes, downloadSize, actions) pkgs_remove = len(self.toRemove) pkgs_inst = len(self.toInstall) pkgs_upgrade = len(self.toUpgrade) msg = "" if pkgs_remove > 0: # FIXME: make those two seperate lines to make it clear # that the "%" applies to the result of ngettext msg += gettext.ngettext("%d package is going to be removed.", "%d packages are going to be removed.", pkgs_remove) % pkgs_remove msg += " " if pkgs_inst > 0: msg += gettext.ngettext("%d new package is going to be " "installed.", "%d new packages are going to be " "installed.",pkgs_inst) % pkgs_inst msg += " " if pkgs_upgrade > 0: msg += gettext.ngettext("%d package is going to be upgraded.", "%d packages are going to be upgraded.", pkgs_upgrade) % pkgs_upgrade msg +=" " if downloadSize > 0: msg += _("\n\nYou have to download a total of %s. ") %\ apt_pkg.SizeToStr(downloadSize) msg += estimatedDownloadTime(downloadSize) msg += "." if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100: msg += "\n\n%s" % _("Fetching and installing the upgrade can take several hours and "\ "cannot be canceled at any time later.") # Show an error if no actions are planned if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: # FIXME: this should go into DistUpgradeController summary = _("Your system is up-to-date") msg = _("There are no upgrades available for your system. " "The upgrade will now be canceled.") self.error(summary, msg) return False return self.askYesNoQuestion(summary, msg)
def confirmChanges(self, summary, changes, downloadSize, actions=None): DistUpgradeView.confirmChanges(self, summary, changes, downloadSize, actions) logging.debug("toinstall: '%s'" % self.toInstall) logging.debug("toupgrade: '%s'" % self.toUpgrade) logging.debug("toremove: '%s'" % self.toRemove) return True
def confirmChanges(self, summary, changes, downloadSize, actions=None): # FIXME: add a whitelist here for packages that we expect to be # removed (how to calc this automatically?) DistUpgradeView.confirmChanges(self, summary, changes, downloadSize) pkgs_remove = len(self.toRemove) pkgs_inst = len(self.toInstall) pkgs_upgrade = len(self.toUpgrade) msg = "" if pkgs_remove > 0: # FIXME: make those two seperate lines to make it clear # that the "%" applies to the result of ngettext msg += gettext.ngettext("%d package is going to be removed.", "%d packages are going to be removed.", pkgs_remove) % pkgs_remove msg += " " if pkgs_inst > 0: msg += gettext.ngettext("%d new package is going to be " "installed.", "%d new packages are going to be " "installed.",pkgs_inst) % pkgs_inst msg += " " if pkgs_upgrade > 0: msg += gettext.ngettext("%d package is going to be upgraded.", "%d packages are going to be upgraded.", pkgs_upgrade) % pkgs_upgrade msg +=" " if downloadSize > 0: msg += _("\n\nYou have to download a total of %s. ") %\ apt_pkg.SizeToStr(downloadSize) msg += estimatedDownloadTime(downloadSize) msg += "." if (pkgs_upgrade + pkgs_inst + pkgs_remove) > 100: msg += "\n\n%s" % _("Fetching and installing the upgrade can take several hours and "\ "cannot be canceled at any time later.") msg += "\n\n<b>%s</b>" % _("To prevent data loss close all open "\ "applications and documents.") # Show an error if no actions are planned if (pkgs_upgrade + pkgs_inst + pkgs_remove) < 1: # FIXME: this should go into DistUpgradeController summary = _("Your system is up-to-date") msg = _("There are no upgrades available for your system. " "The upgrade will now be canceled.") self.error(summary, msg) return False if actions != None: self.button_cancel_changes.set_use_stock(False) self.button_cancel_changes.set_use_underline(True) self.button_cancel_changes.set_label(actions[0]) self.button_confirm_changes.set_label(actions[1]) self.label_summary.set_markup("<big><b>%s</b></big>" % summary) self.label_changes.set_markup(msg) # fill in the details self.details_list.clear() for rm in self.toRemove: self.details_list.append([_("<b>Remove %s</b>") % rm]) for inst in self.toInstall: self.details_list.append([_("Install %s") % inst]) for up in self.toUpgrade: self.details_list.append([_("Upgrade %s") % up]) self.treeview_details.scroll_to_cell((0,)) self.dialog_changes.set_transient_for(self.window_main) self.dialog_changes.realize() self.dialog_changes.window.set_functions(gtk.gdk.FUNC_MOVE) res = self.dialog_changes.run() self.dialog_changes.hide() if res == gtk.RESPONSE_YES: return True return False