[Sugar-devel] [PATCH GetBooks] Report when could not reach the server SL #3180

Anish Mangal anish at activitycentral.com
Thu May 17 13:22:27 EDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 16 May 2012 06:18 PM, Manuel Kaufmann wrote:
> 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 at 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/GetIABooksActivity.py +++
> b/GetIABooksActivity.py @@ -20,6 +20,8 @@ import os import logging 
> import time import gtk +import urllib2 +import socket
> 
> OLD_TOOLBAR = False try: @@ -798,7 +800,18 @@ class
> GetIABooksActivity(activity.Activity):
> 
> def __query_updated_cb(self, query, midway): 
> self.listview.populate(self.queryresults) -        if
> (len(self.queryresults.get_catalog_list()) > 0): +        if
> 'bozo_exception' in self.queryresults._feedobj: +            #
> something went wrong and we have to inform about this +
> bozo_exception = self.queryresults._feedobj.bozo_exception +
> if isinstance(bozo_exception, urllib2.URLError): +
> if isinstance(bozo_exception.reason, socket.gaierror): +
> if bozo_exception.reason.errno == -2: +
> self.show_message(_('Could not reach the server. ' +
> 'Maybe you are not connected to the network'))

Perhaps a better message would be. "Sorry, no books could be found.
Please check if you are connected to the network"

> +                        self.window.set_cursor(None) +
> return


> +            self.show_message(_('There was an error downloading
> the list.'))

This could be put in an else block to make it more explicit codewise.

            else:
                self.show_message(_('There was an error downloading
the list.'))

Also, have the similar generic message here:

"Sorry, there was an error. No books could be found."

> +        elif (len(self.queryresults.get_catalog_list()) > 0): 
> self.show_message(_('New catalog list %s was found') \ %
> self.queryresults._configuration["name"]) 
> self.catalogs_updated(query, midway)


Just my 2 cents

- --
Anish
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPtTPTAAoJEBoxUdDHDZVpBxoH/iVnBkMM+1AP9NgHjIKZDA/2
WpjQ+Orb/HHD99yi4OuWdbqQDwaCLgVLz6Eq446ABHjDJGECoBySyPh5oUtsRJzM
KJ9w2XUWK9git0RkHfr+/LJptBBwH1DuZvdOxim/OFe0NEotQWaZL2Y/Txa2D5Bg
f4bsljofs57Gy5sTPTaBrdly69fjQKfMqUQ3F7PYda6c+OnIEK1M9Fz/o1SV8e7X
HG9IFVce2t5r0Soy1nSLCxj2m00AlxjAT0YWgobxCDoz1Q+gIHYN0ez5dcpLk8uj
z/AkuIXTYJVZmOq66oTDASAweZfIAilxt+r4exGMQB6R0lEVJBWc+uZ0cbEVrLg=
=ZUr/
-----END PGP SIGNATURE-----


More information about the Sugar-devel mailing list