From 6dc03d7c6e36a9f32e07cd23852ed3cb0567daec Mon Sep 17 00:00:00 2001
From: Ajay Garg <ajay@sugarlabs.org>
Date: Fri, 9 Dec 2011 23:16:55 +0530
Subject: [PATCH 2/2] sl#3194: Notify user of connection-not-available, in
Software-Update
Organization: Sugar Labs Foundation
Now, if the internet connection is not available at the time when user
enters "Software Update", the message 'Cannot check for updates, please
check your internet connection, and try running Software Update again'
is shown.
Signed-off-by: Ajay Garg <ajay@sugarlabs.org>
---
.../cpsection/updater/backends/microformat.py | 16 +++++++++++-----
extensions/cpsection/updater/model.py | 1 +
extensions/cpsection/updater/view.py | 2 ++
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/extensions/cpsection/updater/backends/microformat.py b/extensions/cpsection/updater/backends/microformat.py
index 97499aa..b102146 100644
a
|
b
|
_ACTIVITIES_LIST = {} |
33 | 33 | ACTION_CHECKING = 0 |
34 | 34 | ACTION_UPDATING = 1 |
35 | 35 | ACTION_DOWNLOADING = 2 |
| 36 | ACTION_ABORTING = 3 |
36 | 37 | |
37 | 38 | class MicroformatParser(HTMLParser): |
38 | 39 | |
… |
… |
class _UpdateFetcher(gobject.GObject): |
175 | 176 | def __read_async_cb(self, gfile, result): |
176 | 177 | try: |
177 | 178 | stream = gfile.read_finish(result) |
178 | | except gio.Error, e: |
179 | | self.stop() |
180 | | logging.exception('Error while fetching content from %s' % |
181 | | self._url) |
| 179 | stream.read_async(4096, self.__stream_read_cb) |
| 180 | except: |
| 181 | # Note : Not raising an exception. |
| 182 | # Instead, emitting the 'progress' |
| 183 | # signal, so that the corresponding |
| 184 | # callback handles the situation |
| 185 | # appropriately. |
| 186 | self.emit('progress', ACTION_ABORTING, 'Cannot check for ' |
| 187 | 'updates.\nPlease check your internet connection, ' |
| 188 | '\nand try running Software Update again.', 0, 3) |
182 | 189 | return |
183 | | stream.read_async(4096, self.__stream_read_cb) |
184 | 190 | |
185 | 191 | def __stream_read_cb(self, stream, result): |
186 | 192 | data = stream.read_finish(result) |
diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
index 39d0b1f..5d239ac 100755
a
|
b
|
class UpdateModel(gobject.GObject): |
70 | 70 | ACTION_CHECKING = 0 |
71 | 71 | ACTION_UPDATING = 1 |
72 | 72 | ACTION_DOWNLOADING = 2 |
| 73 | ACTION_ABORTING = 3 |
73 | 74 | |
74 | 75 | def __init__(self): |
75 | 76 | gobject.GObject.__init__(self) |
diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
index b4e1fc3..40da44c 100644
a
|
b
|
class ActivityUpdater(SectionView): |
127 | 127 | message = _('Downloading %s...') % bundle_name |
128 | 128 | elif action == UpdateModel.ACTION_UPDATING: |
129 | 129 | message = _('Updating %s...') % bundle_name |
| 130 | elif action == UpdateModel.ACTION_ABORTING: |
| 131 | message = _('%s') % bundle_name |
130 | 132 | |
131 | 133 | self._switch_to_progress_pane() |
132 | 134 | self._progress_pane.set_message(message) |