[hack] show a dialog when there's no available network connection, but at least don't traceback
This commit is contained in:
parent
8797223ccd
commit
89d40971fe
@ -6,6 +6,7 @@ import dbus
|
|||||||
import cgi
|
import cgi
|
||||||
import xml.sax.saxutils
|
import xml.sax.saxutils
|
||||||
import gobject
|
import gobject
|
||||||
|
import socket
|
||||||
|
|
||||||
from google import google
|
from google import google
|
||||||
from sugar.presence.PresenceService import PresenceService
|
from sugar.presence.PresenceService import PresenceService
|
||||||
@ -26,6 +27,7 @@ class SearchModel(gtk.ListStore):
|
|||||||
def __init__(self, activities_model, search_text):
|
def __init__(self, activities_model, search_text):
|
||||||
gtk.ListStore.__init__(self, gobject.TYPE_STRING, gobject.TYPE_STRING,
|
gtk.ListStore.__init__(self, gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||||
gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
|
gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
|
||||||
|
success = False
|
||||||
|
|
||||||
for row in activities_model:
|
for row in activities_model:
|
||||||
title = row[_COLUMN_TITLE]
|
title = row[_COLUMN_TITLE]
|
||||||
@ -34,8 +36,18 @@ class SearchModel(gtk.ListStore):
|
|||||||
self.append([ title, address, row[_COLUMN_SUBTITLE], row[_COLUMN_SERVICE] ])
|
self.append([ title, address, row[_COLUMN_SUBTITLE], row[_COLUMN_SERVICE] ])
|
||||||
|
|
||||||
google.LICENSE_KEY = '1As9KaJQFHIJ1L0W5EZPl6vBOFvh/Vaf'
|
google.LICENSE_KEY = '1As9KaJQFHIJ1L0W5EZPl6vBOFvh/Vaf'
|
||||||
|
try:
|
||||||
data = google.doGoogleSearch(search_text)
|
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:
|
for result in data.results:
|
||||||
title = result.title
|
title = result.title
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user