diff options
| author | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-01-26 15:53:46 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebastian.heinlein@web.de> | 2006-01-26 15:53:46 +0100 |
| commit | 5c7cce315d65d96a744c91d4cec10a3a135b3a51 (patch) | |
| tree | 5a7507f50990b902dbed751bd5c055a52238277b /DistUpgrade | |
| parent | 7e1b71667312232f492fe8288be6da68c4400e59 (diff) | |
| parent | 52ba94d286981672f3b05c08911e19e633e48568 (diff) | |
| download | python-apt-5c7cce315d65d96a744c91d4cec10a3a135b3a51.tar.gz | |
* merged from mvo
* remove the commented line about hiding the progress bar at the end of
the installation. the full progress bar is importnat to indicate the
end of the upgrade. so i don't see any need to perhaps uncomment this
again in the future
Diffstat (limited to 'DistUpgrade')
| -rw-r--r-- | DistUpgrade/DistUpgradeControler.py | 50 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeViewGtk.py | 33 |
2 files changed, 70 insertions, 13 deletions
diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index a0f5a642..229b7107 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -191,19 +191,42 @@ class DistUpgradeControler(object): self.cache.requiredDownload) return res - def doDistUpgrade(self): + def doDistUpgrade(self, currentTry=0): + currentRetry = 0 fprogress = self._view.getFetchProgress() iprogress = self._view.getInstallProgress() - try: - res = self.cache.commit(fprogress,iprogress) - except (SystemError, IOError), e: - self._view.error(_("Error during commit"), - _("Some problem occured during the upgrade. " - "This is mostly a network problem, please " - "check the network and try again. "), - "%s" % e) - return False - return True + # retry the fetching in case of errors + while currentRetry < 3: + try: + res = self.cache.commit(fprogress,iprogress) + except SystemError, e: + # installing the packages failed, can't be retried + self._view.error(_("Error during commit"), + _("Some problem occured during the upgrade. " + "Most likely packages failed to install. " + "Try 'sudo apt-get install -f' or synaptic " + "to fix your system."), + "%s" % e) + return False + except IOError, e: + # fetch failed, will be retried + logging.error("IOError in cache.commit(): '%s'. Retrying (currentTry: %s)" % (e,currentTry)) + currentRetry += 1 + continue + # no exception, so all was fine, we are done + return True + + # maximum fetch-retries reached without a successful commit + logging.debug("giving up on fetching after maximum retries") + self._view.error(_("Error fetching the packages"), + _("Some problem occured during the fetching " + "of the packages. This is most likely a network " + "problem. Please check your network and try " + "again. "), + "%s" % e) + # abort here because we want our sources.list back + self.abort() + def doPostUpgrade(self): @@ -282,11 +305,12 @@ class DistUpgradeControler(object): self._view.updateStatus(_("Upgrading")) if not self.doDistUpgrade(): - self.abort() + # don't abort here, because it would restore the sources.list + sys.exit(1) # do post-upgrade stuff self._view.setStep(4) - self._view.updateStatus(_("Searching for obsolete software")) + self._view.updateStatus(_("Searching for obsolete software")) self.doPostUpgrade() # done, ask for reboot diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 9ba1a04c..94090322 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -199,6 +199,8 @@ class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp): self.treeview_details.append_column(column) self.treeview_details.set_model(self.details_list) self.vscrollbar_terminal.set_adjustment(self._term.get_adjustment()) + # work around bug in VteTerminal here + self._term.realize() # Use italic style in the status labels attrlist=pango.AttrList() @@ -206,11 +208,42 @@ class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp): attrlist.insert(attr) self.label_status.set_property("attributes", attrlist) + # reasonable fault handler + sys.excepthook = self._handleException + + def _handleException(self, type, value, tb): + import traceback + lines = traceback.format_exception(type, value, tb) + logging.error("not handled expection:\n%s" % "\n".join(lines)) + self.error(_("A fatal error occured"), + _("During the operation a fatal error occured. " + "Please report this as a bug and include the " + "files ~/dist-upgrade.log and ~/dist-upgrade-apt.log " + "in your report. The upgrade will abort now. "), + "\n".join(lines)) + def create_terminal(self, arg1,arg2,arg3,arg4): " helper to create a vte terminal " self._term = vte.Terminal() self._term.set_font_from_string("monospace 10") + self._term.connect("contents-changed", self._term_content_changed) + self._terminal_lines = [] + self._terminal_log = open(os.path.expanduser("~/dist-upgrade-term.log"),"w") return self._term + def _term_content_changed(self, term): + " called when the *visible* part of the terminal changes " + + # get the current visible text, + current_text = self._term.get_text(lambda a,b,c,d: True) + # see what we have currently and only print stuff that wasn't + # visible last time + new_lines = [] + for line in current_text.split("\n"): + new_lines.append(line) + if not line in self._terminal_lines: + self._terminal_log.write(line+"\n") + self._terminal_log.flush() + self._terminal_lines = new_lines def getFetchProgress(self): return self._fetchProgress def getInstallProgress(self): |
