Ticket #3180: 0001-Report-when-could-not-reach-the-server-SL-3180.patch

File 0001-Report-when-could-not-reach-the-server-SL-3180.patch, 2.1 KB (added by humitos, 12 years ago)
  • GetIABooksActivity.py

    From 5344e675859a2c3c2ce41ba3bf083cb1348d7543 Mon Sep 17 00:00:00 2001
    Message-Id: <5344e675859a2c3c2ce41ba3bf083cb1348d7543.1337172332.git.humitos@gmail.com>
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Wed, 16 May 2012 09:45:21 -0300
    Subject: [PATCH GetBooks] Report when could not reach the server SL #3180
    
    Handled urllib2.URLError returned by feedparser to inform the user
    about this problem, saying that maybe he is not connected to the
    network.
    
    If there were another problem downloading the list, the user is
    informed with a generic message.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     GetIABooksActivity.py |   15 ++++++++++++++-
     1 file changed, 14 insertions(+), 1 deletion(-)
    
    diff --git a/GetIABooksActivity.py b/GetIABooksActivity.py
    index 0a06069..bc132f9 100644
    a b import os 
    2020import logging
    2121import time
    2222import gtk
     23import urllib2
     24import socket
    2325
    2426OLD_TOOLBAR = False
    2527try:
    class GetIABooksActivity(activity.Activity): 
    798800
    799801    def __query_updated_cb(self, query, midway):
    800802        self.listview.populate(self.queryresults)
    801         if (len(self.queryresults.get_catalog_list()) > 0):
     803        if 'bozo_exception' in self.queryresults._feedobj:
     804            # something went wrong and we have to inform about this
     805            bozo_exception = self.queryresults._feedobj.bozo_exception
     806            if isinstance(bozo_exception, urllib2.URLError):
     807                if isinstance(bozo_exception.reason, socket.gaierror):
     808                    if bozo_exception.reason.errno == -2:
     809                        self.show_message(_('Could not reach the server. '
     810                            'Maybe you are not connected to the network'))
     811                        self.window.set_cursor(None)
     812                        return
     813            self.show_message(_('There was an error downloading the list.'))
     814        elif (len(self.queryresults.get_catalog_list()) > 0):
    802815            self.show_message(_('New catalog list %s was found') \
    803816                % self.queryresults._configuration["name"])
    804817            self.catalogs_updated(query, midway)