Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha@silbe.org>2010-03-09 10:03:43 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2010-03-09 10:03:43 (GMT)
commitbb08478eff76d53f6969cb3d21431ff12630b1f7 (patch)
treeb2a916e815b578f56082ae42dc51246d18dc35d2
parentd9857d179c41ebfa40321a7d0df1f84a18478155 (diff)
fail gracefully if system DBus unreachable (#1401)
System bus (DBus) is only required for optional features (NetworkManager and Avahi support), so fail gracefully (but output errors to logs) if it is unreachable. This aids testing Sugar inside chroots. Tested: - inside chroot (no system bus): Jabber: neighbourhood shows buddies, Salut: neighbourhood empty (expected - Salut requires Avahi) - on XO-1 (regular session, no NM): Jabber+Salut: neighbourhood shows buddies - on XO-1 (regular session, NM): Jabber+Salut: neighbourhood shows buddies Signed-off-by: Sascha Silbe <sascha@silbe.org>
-rw-r--r--src/linklocal_plugin.py17
-rw-r--r--src/psutils.py20
2 files changed, 28 insertions, 9 deletions
diff --git a/src/linklocal_plugin.py b/src/linklocal_plugin.py
index eb44ca5..051797e 100644
--- a/src/linklocal_plugin.py
+++ b/src/linklocal_plugin.py
@@ -22,7 +22,7 @@ from itertools import izip
# Other libraries
import gobject
-from dbus import SystemBus
+from dbus import DBusException, SystemBus
from telepathy.client import Connection
from telepathy.interfaces import CONN_INTERFACE
from telepathy.constants import HANDLE_TYPE_CONTACT
@@ -53,14 +53,21 @@ class LinkLocalPlugin(TelepathyPlugin):
def __init__(self, registry, owner):
TelepathyPlugin.__init__(self, registry, owner)
- self._sys_bus = SystemBus()
self._have_avahi = False
- self._watch = self._sys_bus.watch_name_owner('org.freedesktop.Avahi',
- self._avahi_owner_cb)
-
+ self._watch = None
# Glib source ID indicating we have to wait before be allowed to try
# to connect
self._have_to_wait_id = 0
+ self._find_avahi()
+
+ def _find_avahi(self):
+ try:
+ sys_bus = SystemBus()
+ self._watch = sys_bus.watch_name_owner('org.freedesktop.Avahi',
+ self._avahi_owner_cb)
+
+ except DBusException:
+ _logger.exception('Error connecting to Avahi')
def _avahi_owner_cb(self, unique_name):
had_avahi = self._have_avahi
diff --git a/src/psutils.py b/src/psutils.py
index feabefe..6e6b2b6 100644
--- a/src/psutils.py
+++ b/src/psutils.py
@@ -159,10 +159,22 @@ class IP4AddressMonitor(gobject.GObject):
self._matches = []
self._addr = None
self._nm_iface = None
- self._sys_bus = dbus.SystemBus()
- self._watch = self._sys_bus.watch_name_owner(_NM_SERVICE,
- self._nm_owner_cb)
- if not self._sys_bus.name_has_owner(_NM_SERVICE):
+ self._sys_bus = None
+ self._watch = None
+ self._find_network_manager()
+
+ def _find_network_manager(self):
+ found = False
+ try:
+ self._sys_bus = dbus.SystemBus()
+ self._watch = self._sys_bus.watch_name_owner(_NM_SERVICE,
+ self._nm_owner_cb)
+ found = self._sys_bus.name_has_owner(_NM_SERVICE)
+
+ except DBusException:
+ _logger.exception('Error connecting to NetworkManager')
+
+ if not found:
addr, iface = self._get_address_fallback()
self._update_address(addr, iface)