Ticket #3194: 0002-sl-3194-Notify-user-of-connection-not-available-in-S.patch

File 0002-sl-3194-Notify-user-of-connection-not-available-in-S.patch, 3.3 KB (added by ajay_garg, 12 years ago)
  • extensions/cpsection/updater/backends/microformat.py

    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 = {} 
    3333ACTION_CHECKING = 0
    3434ACTION_UPDATING = 1
    3535ACTION_DOWNLOADING = 2
     36ACTION_ABORTING = 3
    3637
    3738class MicroformatParser(HTMLParser):
    3839
    class _UpdateFetcher(gobject.GObject): 
    175176    def __read_async_cb(self, gfile, result):
    176177        try:
    177178            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)
    182189            return
    183         stream.read_async(4096, self.__stream_read_cb)
    184190
    185191    def __stream_read_cb(self, stream, result):
    186192        data = stream.read_finish(result)
  • extensions/cpsection/updater/model.py

    diff --git a/extensions/cpsection/updater/model.py b/extensions/cpsection/updater/model.py
    index 39d0b1f..5d239ac 100755
    a b class UpdateModel(gobject.GObject): 
    7070    ACTION_CHECKING = 0
    7171    ACTION_UPDATING = 1
    7272    ACTION_DOWNLOADING = 2
     73    ACTION_ABORTING = 3
    7374
    7475    def __init__(self):
    7576        gobject.GObject.__init__(self)
  • extensions/cpsection/updater/view.py

    diff --git a/extensions/cpsection/updater/view.py b/extensions/cpsection/updater/view.py
    index b4e1fc3..40da44c 100644
    a b class ActivityUpdater(SectionView): 
    127127            message = _('Downloading %s...') % bundle_name
    128128        elif action == UpdateModel.ACTION_UPDATING:
    129129            message = _('Updating %s...') % bundle_name
     130        elif action == UpdateModel.ACTION_ABORTING:
     131            message = _('%s') % bundle_name
    130132
    131133        self._switch_to_progress_pane()
    132134        self._progress_pane.set_message(message)