]> git.meshlink.io Git - catta/commitdiff
display a graphical error message when the deamon is not running
authorSebastien Estienne <sebastien.estienne@gmail.com>
Sun, 17 Dec 2006 11:22:17 +0000 (11:22 +0000)
committerSebastien Estienne <sebastien.estienne@gmail.com>
Sun, 17 Dec 2006 11:22:17 +0000 (11:22 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1343 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-python/avahi-discover.in

index 53bb2ce8c3d0f0b13a2ec2146d7befe56f78c847..ce7ecf33e822877d5d99846c23e0f19e63d54930 100755 (executable)
@@ -24,8 +24,8 @@ import os, sys
 try:
     import avahi, gtk, gobject, dbus, avahi.ServiceTypeDatabase
     from avahi.SimpleGladeApp import SimpleGladeApp
-except ImportError:
-    print "Sorry, to use this tool you need to install Avahi, pygtk and python-dbus."
+except ImportError, e:
+    print "Sorry, to use this tool you need to install Avahi, pygtk and python-dbus.\n Error: %s" % e
     sys.exit(1)
 
 
@@ -33,6 +33,8 @@ except ImportError:
 # It's really important to do this, else you won't see any events
 ##
 try:
+from dbus.dbus_bindings import DBusException
+
     import dbus.glib
 except ImportError, e:
     pass
@@ -40,6 +42,14 @@ except ImportError, e:
 service_type_browsers = {}
 service_browsers = {}
 
+def error_msg(msg):
+    d = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL,
+                          type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
+    d.set_markup(msg)
+    d.show_all()
+    d.run()
+    d.destroy()
+
 glade_dir = "@interfacesdir@"
 
 service_type_db = avahi.ServiceTypeDatabase.ServiceTypeDatabase()
@@ -162,8 +172,14 @@ class Main_window(SimpleGladeApp):
 
         if self.stype is None:
             print "Browsing domain '%s' on %i.%i ..." % (domain, interface, protocol)
-        
-            b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceTypeBrowserNew(interface, protocol, domain, dbus.UInt32(0))),  avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER)
+
+            try:
+                b = dbus.Interface(self.bus.get_object(avahi.DBUS_NAME, self.server.ServiceTypeBrowserNew(interface, protocol, domain, dbus.UInt32(0))),  avahi.DBUS_INTERFACE_SERVICE_TYPE_BROWSER)
+            except DBusException, e:
+                print e
+                error_msg("You should check that the avahi daemon is running.\n\nError : %s" % e)
+                sys.exit(0)
+                
             b.connect_to_signal('ItemNew', self.new_service_type)
 
             service_type_browsers[(interface, protocol, domain)] = b