From: Sebastien Estienne Date: Sun, 17 Dec 2006 11:22:17 +0000 (+0000) Subject: display a graphical error message when the deamon is not running X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=7a237191fe9521c625dee2f09accb7574edd6b4f;p=catta display a graphical error message when the deamon is not running git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1343 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-python/avahi-discover.in b/avahi-python/avahi-discover.in index 53bb2ce..ce7ecf3 100755 --- a/avahi-python/avahi-discover.in +++ b/avahi-python/avahi-discover.in @@ -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