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 |
20 | 20 | import logging |
21 | 21 | import time |
22 | 22 | import gtk |
| 23 | import urllib2 |
| 24 | import socket |
23 | 25 | |
24 | 26 | OLD_TOOLBAR = False |
25 | 27 | try: |
… |
… |
class GetIABooksActivity(activity.Activity): |
798 | 800 | |
799 | 801 | def __query_updated_cb(self, query, midway): |
800 | 802 | 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): |
802 | 815 | self.show_message(_('New catalog list %s was found') \ |
803 | 816 | % self.queryresults._configuration["name"]) |
804 | 817 | self.catalogs_updated(query, midway) |