[Dextrose] [PATCH 1/5][dextrose2][sugar] Updater show error at checking failure
Martin Abente
martin.abente.lahaye at gmail.com
Tue Apr 19 17:21:24 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
---
.../cpsection/updater/backends/microformat.py | 4 +++-
extensions/cpsection/updater/model.py | 1 +
extensions/cpsection/updater/view.py | 10 +++++++++-
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/extensions/cpsection/updater/backends/microformat.py b/extensions/cpsection/updater/backends/microformat.py
index c3c7268..c3d7b18 100644
--- a/extensions/cpsection/updater/backends/microformat.py
+++ b/extensions/cpsection/updater/backends/microformat.py
@@ -32,6 +32,7 @@ _ACTIVITIES_LIST = {}
ACTION_CHECKING = 0
ACTION_UPDATING = 1
ACTION_DOWNLOADING = 2
+ACTION_FAILED = 3
class MicroformatParser(HTMLParser):
@@ -183,7 +184,8 @@ class _UpdateFetcher(gobject.GObject):
try:
stream = gfile.read_finish(result)
except:
- self._completion_cb({}, traceback.format_exc())
+ logging.debug(traceback.format_exc())
+ 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..31cade8 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,11 @@ 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')
+ 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