From 2780bf690f1688a6f2a8771e519088abfb1b4439 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 26 Jan 2006 11:41:33 +0100 Subject: * handle exception with the gui and give advice about bug reporting --- DistUpgrade/DistUpgradeViewGtk.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'DistUpgrade') diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 26fa099c..230c8b47 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -209,6 +209,20 @@ 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() -- cgit v1.2.3 From 617423e33d1bc9b474b1df7b40caff23e5afba45 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 26 Jan 2006 13:14:46 +0100 Subject: * added ~/dist-upgrade-term.log support (output all that is printed on the terminal) --- DistUpgrade/DistUpgradeViewGtk.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'DistUpgrade') diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 230c8b47..9b08ba9c 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -168,7 +168,7 @@ class GtkInstallProgressAdapter(InstallProgress): self.updateInterface() return self.apt_status def finishUpdate(self): - self.progress.hide() + #self.progress.hide() self.label_status.set_text("") def updateInterface(self): InstallProgress.updateInterface(self) @@ -227,7 +227,32 @@ class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp): " 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 " + + # work around stupid vte bug (realize, then scroll to end) + self._term.realize() + ad = self._term.get_adjustment() + ad.set_value(ad.upper - ad.page_size) + ad.value_changed() + + # get the current visible text, + current_text = self._term.get_text(lambda a,b,c,d: True) + print current_text + "\n\n" + + # 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): -- cgit v1.2.3 From df30ebea802ae25732477bd291b27e4169bc7a88 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 26 Jan 2006 13:43:43 +0100 Subject: * less debug output --- DistUpgrade/DistUpgradeViewGtk.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'DistUpgrade') diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 9b08ba9c..94636ef9 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -242,8 +242,6 @@ class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp): # get the current visible text, current_text = self._term.get_text(lambda a,b,c,d: True) - print current_text + "\n\n" - # see what we have currently and only print stuff that wasn't # visible last time new_lines = [] -- cgit v1.2.3 From 9550c7ce6344e3973d89aeff46e4bd385ab3c19d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 26 Jan 2006 14:18:45 +0100 Subject: * workaround bug in VteTerminal for the log support --- DistUpgrade/DistUpgradeViewGtk.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'DistUpgrade') diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 94636ef9..eff02471 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -202,6 +202,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() @@ -234,12 +236,6 @@ class GtkDistUpgradeView(DistUpgradeView,SimpleGladeApp): def _term_content_changed(self, term): " called when the *visible* part of the terminal changes " - # work around stupid vte bug (realize, then scroll to end) - self._term.realize() - ad = self._term.get_adjustment() - ad.set_value(ad.upper - ad.page_size) - ad.value_changed() - # 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 -- cgit v1.2.3 From 52ba94d286981672f3b05c08911e19e633e48568 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 26 Jan 2006 15:08:37 +0100 Subject: * retry automatically on network problems --- DistUpgrade/DistUpgradeControler.py | 50 +++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'DistUpgrade') diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index db6168ef..c7299871 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 -- cgit v1.2.3