diff options
author | Dan Williams <dcbw@redhat.com> | 2006-06-22 16:52:30 (GMT) |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2006-06-22 16:52:30 (GMT) |
commit | 89d40971fe520e4d0fc124743773a9f76174da18 (patch) | |
tree | 12760cdd5e45ef0b615ea2f0be644ceb2ed8327a /shell/StartPage.py | |
parent | 8797223ccd5d3fb3121b47c1a56346d9f9affd15 (diff) |
[hack] show a dialog when there's no available network connection, but at least don't traceback
Diffstat (limited to 'shell/StartPage.py')
-rw-r--r-- | shell/StartPage.py | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/shell/StartPage.py b/shell/StartPage.py index 4ceeec3..a73018a 100644 --- a/shell/StartPage.py +++ b/shell/StartPage.py @@ -6,6 +6,7 @@ import dbus import cgi import xml.sax.saxutils import gobject +import socket from google import google from sugar.presence.PresenceService import PresenceService @@ -26,6 +27,7 @@ class SearchModel(gtk.ListStore): def __init__(self, activities_model, search_text): gtk.ListStore.__init__(self, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) + success = False for row in activities_model: title = row[_COLUMN_TITLE] @@ -34,21 +36,31 @@ class SearchModel(gtk.ListStore): self.append([ title, address, row[_COLUMN_SUBTITLE], row[_COLUMN_SERVICE] ]) google.LICENSE_KEY = '1As9KaJQFHIJ1L0W5EZPl6vBOFvh/Vaf' - data = google.doGoogleSearch(search_text) - - for result in data.results: - title = result.title - - # FIXME what tags should we actually strip? - title = title.replace('<b>', '') - title = title.replace('</b>', '') - - # FIXME I'm sure there is a better way to - # unescape these. - title = title.replace('"', '"') - title = title.replace('&', '&') - - self.append([ title, result.URL, None, None ]) + try: + data = google.doGoogleSearch(search_text) + success = True + except socket.gaierror, exc: + if exc[0] == -3: # Temporary failure in name resolution + errdlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, + gtk.BUTTONS_OK, "There appears to be no network connection.") + errdlg.connect("response", lambda d, e: d.destroy()) + errdlg.connect("close", lambda d, e: d.destroy()) + errdlg.show() + + if success == True: + for result in data.results: + title = result.title + + # FIXME what tags should we actually strip? + title = title.replace('<b>', '') + title = title.replace('</b>', '') + + # FIXME I'm sure there is a better way to + # unescape these. + title = title.replace('"', '"') + title = title.replace('&', '&') + + self.append([ title, result.URL, None, None ]) class ActivitiesModel(gtk.ListStore): def __init__(self): |