bigboard r7288 - in trunk/bigboard: . libbig stocks/mail stocks/people
- From: marinaz svn gnome org
- To: svn-commits-list gnome org
- Subject: bigboard r7288 - in trunk/bigboard: . libbig stocks/mail stocks/people
- Date: Thu, 10 Apr 2008 23:59:02 +0100 (BST)
Author: marinaz
Date: Thu Apr 10 23:59:01 2008
New Revision: 7288
URL: http://svn.gnome.org/viewvc/bigboard?rev=7288&view=rev
Log:
Catch some exceptions that happen when the network connection is down.
Modified:
trunk/bigboard/accounts.py
trunk/bigboard/google.py
trunk/bigboard/libbig/http.py
trunk/bigboard/stocks/mail/MailStock.py
trunk/bigboard/stocks/people/PeopleStock.py
Modified: trunk/bigboard/accounts.py
==============================================================================
--- trunk/bigboard/accounts.py (original)
+++ trunk/bigboard/accounts.py Thu Apr 10 23:59:01 2008
@@ -120,12 +120,18 @@
def _update_from_origin(self, new_props):
"""This is the only way to modify an Account object. It should be invoked only on change notification or refreshed data from the original origin of the account."""
- _logger.debug("updating account from origin %s" % new_props)
+ _logger.debug("updating account from origin")
## check it out!
changed = False
for (key,value) in new_props.items():
if value is None:
value = ''
+
+ if key != "password":
+ _logger.debug("key %s, value %s" % (key, value))
+ else:
+ _logger.debug("key %s, value length %d" % (key, len(value)))
+
old = getattr(self, '_Account__' + key)
if old != value:
setattr(self, '_Account__' + key, value)
Modified: trunk/bigboard/google.py
==============================================================================
--- trunk/bigboard/google.py (original)
+++ trunk/bigboard/google.py Thu Apr 10 23:59:01 2008
@@ -206,11 +206,14 @@
h.follow_all_redirects = True
def __handle_response_error(self, authcb, errcb, url, response, content):
- if response.status == 401:
+ if response and response.status == 401:
_logger.debug("auth failure for fetch of %s; invoking auth callback", url)
gobject.idle_add(lambda: authcb(url) and False)
else:
- _logger.error("caught error for fetch of %s (status %s)", url, response.status)
+ if response:
+ _logger.error("caught error for fetch of %s (status %s)", url, response.status)
+ else:
+ _logger.error("caught error for fetch of %s, response is None, possibly the network connection is down", url)
# in my experience sys.exc_info() is some kind of junk here, while "e" is useful
gobject.idle_add(lambda: errcb(url, response) and False)
Modified: trunk/bigboard/libbig/http.py
==============================================================================
--- trunk/bigboard/libbig/http.py (original)
+++ trunk/bigboard/libbig/http.py Thu Apr 10 23:59:01 2008
@@ -1,5 +1,5 @@
import os,sys
-import threading, logging, urllib2, cookielib, urllib, StringIO
+import threading, logging, urllib2, cookielib, urllib, StringIO, httplib
import xml.dom.minidom, urlparse
import gobject
@@ -159,8 +159,15 @@
headers['Cache-Control'] = 'only-if-cached'
if 'no_store' in kwargs:
headers['Cache-Control'] = 'no-store'
- (response, content) = h.request(url, **http_kwargs)
- if response.status == 200:
+
+ response = None
+ content = None
+ try:
+ (response, content) = h.request(url, **http_kwargs)
+ except (httplib2.ServerNotFoundError, httplib.HTTPException):
+ pass
+
+ if response and response.status == 200:
resultfn = lambda: self.__emit_results(url, kwargs['cb'], content, is_refetch=is_refetch)
if is_refetch:
resultfn()
@@ -169,7 +176,10 @@
elif 'response_errcb' in kwargs:
gobject.idle_add(lambda: kwargs['response_errcb'](url, response, content))
elif 'refetch' not in kwargs:
- self.__logger.info("caught error %s (%s) for fetch of %s: %s" % (url, response.status, response.reason, content))
+ if response:
+ self.__logger.info("caught error %s (%s) for fetch of %s: %s" % (url, response.status, response.reason, content))
+ else:
+ self.__logger.info("did not get any response for fetch of %s; possibly the network connection is down" % url)
if 'errcb' in kwargs:
gobject.idle_add(lambda: kwargs['errcb'](url, response) and False)
if is_refetch:
Modified: trunk/bigboard/stocks/mail/MailStock.py
==============================================================================
--- trunk/bigboard/stocks/mail/MailStock.py (original)
+++ trunk/bigboard/stocks/mail/MailStock.py Thu Apr 10 23:59:01 2008
@@ -1,4 +1,4 @@
-import logging, re, htmlentitydefs, time
+import logging, re, htmlentitydefs, time, urllib2
import gobject, gtk
import hippo
@@ -202,7 +202,7 @@
self._box.append(footer)
print "updated mailbox"
- except libgmail.GmailLoginFailure:
+ except (libgmail.GmailLoginFailure, urllib2.URLError):
self._box.remove_all()
if self._login_button.get_property("text") == google_stock.CHECKING_LOGIN_STRING:
error = hippo.CanvasText(text=google_stock.FAILED_TO_CONNECT_STRING, size_mode=hippo.CANVAS_SIZE_WRAP_WORD)
Modified: trunk/bigboard/stocks/people/PeopleStock.py
==============================================================================
--- trunk/bigboard/stocks/people/PeopleStock.py (original)
+++ trunk/bigboard/stocks/people/PeopleStock.py Thu Apr 10 23:59:01 2008
@@ -78,7 +78,7 @@
box.insert_sorted(item, hippo.PACK_IF_FITS, lambda a,b: sort_people(a.person, b.person))
item.connect('sort-changed', resort)
- # A PersonItem might be pressed, but not be activated, if am IM status portion
+ # A PersonItem might be pressed, but not activated, if an IM status portion
# of it got pressed and resulted in an IM chat window being opened. So we have
# to handle this event in two steps here.
item.connect('button-press-event', self.__handle_item_pressed)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]