From 93333ed5cfd04ba8de58e96a9872d9ac494cc780 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 5 Jun 2006 10:47:14 -0400 Subject: [PATCH] Ignore avahi 'Local name collision' exceptions for now, but this should really get fixed --- sugar/p2p/presence.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sugar/p2p/presence.py b/sugar/p2p/presence.py index d0f6000e..9d11d7e4 100644 --- a/sugar/p2p/presence.py +++ b/sugar/p2p/presence.py @@ -1,6 +1,6 @@ # -*- tab-width: 4; indent-tabs-mode: t -*- -import avahi, dbus, dbus.glib +import avahi, dbus, dbus.glib, dbus_bindings ACTION_SERVICE_NEW = 'new' ACTION_SERVICE_REMOVED = 'removed' @@ -92,8 +92,15 @@ class PresenceAnnounce(object): rs_name = self._hostname info = ["%s=%s" % (k, v) for k, v in kwargs.items()] - g.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, 0, rs_name, rs_service, - "", "", # domain, host (let the system figure it out) - dbus.UInt16(rs_port), info,) - g.Commit() + try: + g.AddService(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, 0, rs_name, rs_service, + "", "", # domain, host (let the system figure it out) + dbus.UInt16(rs_port), info,) + g.Commit() + except dbus_bindings.DBusException, exc: + # FIXME: ignore local name collisions, since that means + # the zeroconf service is already registered. Ideally we + # should un-register it an re-register with the correct info + if str(exc) == "Local name collision": + pass return g