[Dextrose] [PATCH 3/5][dextrose2][sugar] Updater show failed updates number
Martin Abente
martin.abente.lahaye at gmail.com
Tue Apr 19 17:21:26 EDT 2011
Previously, even if a particular update failed, the updater
would only show the total number of activties it _tried_ to
update. This could confuse the users.
This patch will also display the number of updates that failed.
---
extensions/cpsection/updater/model.py | 7 +++++++
extensions/cpsection/updater/view.py | 18 ++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
index 3342ffe..9f27924 100755
--- a/extensions/cpsection/updater/model.py
+++ b/extensions/cpsection/updater/model.py
@@ -78,6 +78,7 @@ class UpdateModel(gobject.GObject):
self._bundles_to_check = None
self._bundles_to_update = None
self._total_bundles_to_update = 0
+ self._total_bundles_failed = 0
self._downloader = None
self._cancelling = False
@@ -176,6 +177,8 @@ class UpdateModel(gobject.GObject):
self._install_update(self._downloader.bundle_update,
self._downloader.get_local_file_path())
else:
+ self._total_bundles_failed += 1
+
total = self._total_bundles_to_update
current = total - len(self._bundles_to_update)
self.emit('progress', UpdateModel.ACTION_UPDATING, '', current, total)
@@ -186,6 +189,9 @@ class UpdateModel(gobject.GObject):
# do it in idle so the UI has a chance to refresh
gobject.idle_add(self._download_next_update)
+ def get_failed_updates(self):
+ return self._total_bundles_failed
+
def _install_update(self, bundle_update, local_file_path):
total = self._total_bundles_to_update
@@ -238,6 +244,7 @@ class UpdateModel(gobject.GObject):
self._downloader = None
self._total_bundles_to_update = 0
+ self._total_bundles_failed = 0
self._bundles_to_update = None
self._cancelling = False
diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
index 31cade8..a59b1f8 100644
--- a/extensions/cpsection/updater/view.py
+++ b/extensions/cpsection/updater/view.py
@@ -121,7 +121,8 @@ class ActivityUpdater(SectionView):
self._finished_checking()
return
elif current == total:
- self._finished_updating(int(current))
+ failed = model.get_failed_updates()
+ self._finished_updating(int(current), failed)
return
if action == UpdateModel.ACTION_CHECKING:
@@ -175,11 +176,20 @@ class ActivityUpdater(SectionView):
def __cancel_button_clicked_cb(self, button):
self._model.cancel()
- def _finished_updating(self, installed_updates):
+ def _finished_updating(self, installed_updates, failed_updates):
logging.debug('ActivityUpdater._finished_updating')
+ success_updates = installed_updates - failed_updates
top_message = ngettext('%s update was installed',
- '%s updates were installed', installed_updates)
- top_message = top_message % installed_updates
+ '%s updates were installed', success_updates)
+ top_message = top_message % success_updates
+
+ if failed_updates > 0:
+ failed_message = ngettext(' and %s update failed',
+ ' and %s updates failed',
+ failed_updates)
+ failed_message = failed_message % failed_updates
+ top_message += failed_message
+
top_message = gobject.markup_escape_text(top_message)
self._top_label.set_markup('<big>%s</big>' % top_message)
self._clear_center()
--
1.7.4.4
More information about the Dextrose
mailing list