[Dextrose] [PATCH 1/5] Updater show error at checking failure

Martin Abente martin.abente.lahaye at gmail.com
Fri Apr 22 17:33:07 EDT 2011


Show error message when the update activity service
is not present, reachable or in case of errors while
downloading the microformat file.

Fixes #2616

version2: Added silbe's comments.
---
 .../cpsection/updater/backends/microformat.py      |    5 +++--
 extensions/cpsection/updater/model.py              |    1 +
 extensions/cpsection/updater/view.py               |   11 ++++++++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/extensions/cpsection/updater/backends/microformat.py b/extensions/cpsection/updater/backends/microformat.py
index c3c7268..0fd7ebd 100644
--- a/extensions/cpsection/updater/backends/microformat.py
+++ b/extensions/cpsection/updater/backends/microformat.py
@@ -24,7 +24,6 @@ import re
 import gio
 import gobject
 import gconf
-import traceback
 
 from jarabe import config
 
@@ -32,6 +31,7 @@ _ACTIVITIES_LIST = {}
 ACTION_CHECKING = 0
 ACTION_UPDATING = 1
 ACTION_DOWNLOADING = 2
+ACTION_FAILED = 3
 
 class MicroformatParser(HTMLParser):
 
@@ -183,7 +183,8 @@ class _UpdateFetcher(gobject.GObject):
         try:
             stream = gfile.read_finish(result)
         except:
-            self._completion_cb({}, traceback.format_exc())
+            logging.exception('Failed to download microformat file')
+            self.emit('progress', ACTION_FAILED, '', -1, -1)
             return
 
         stream.read_async(4096, self.__stream_read_cb)
diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
index ff2eb2c..9bbb506 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -69,6 +69,7 @@ class UpdateModel(gobject.GObject):
     ACTION_CHECKING = 0
     ACTION_UPDATING = 1
     ACTION_DOWNLOADING = 2
+    ACTION_FAILED = 3
 
     def __init__(self):
         gobject.GObject.__init__(self)
diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
index d8afea5..26b4455 100644
--- a/extensions/cpsection/updater/view.py
+++ b/extensions/cpsection/updater/view.py
@@ -114,7 +114,10 @@ class ActivityUpdater(SectionView):
             self._update_box = None
 
     def __progress_cb(self, model, action, bundle_name, current, total):
-        if current == total and action == UpdateModel.ACTION_CHECKING:
+        if action == UpdateModel.ACTION_FAILED:
+            self._failed_at_checking()
+            return
+        elif current == total and action == UpdateModel.ACTION_CHECKING:
             self._finished_checking()
             return
         elif current == total:
@@ -132,6 +135,12 @@ class ActivityUpdater(SectionView):
         self._progress_pane.set_message(message)
         self._progress_pane.set_progress(current / float(total))
 
+    def _failed_at_checking(self):
+        top_message = _('Update service is not available')
+        top_message = gobject.markup_escape_text(top_message)
+        self._top_label.set_markup('<big>%s</big>' % top_message)
+        self._clear_center()
+
     def _finished_checking(self):
         logging.debug('ActivityUpdater._finished_checking')
         available_updates = len(self._model.updates)
-- 
1.7.4.4



More information about the Dextrose mailing list