From 08b278a01d1c96ff8a04c868acb3d744ce1092e4 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Mon, 11 Jan 2010 21:04:48 +0000 Subject: fail gracefully if system DBus unreachable (#1403) System bus (DBus) is only required for optional features (non-permanent connection to jabber server, removable media, etc.), so fail gracefully (but output errors to logs) if it is unreachable. This aids testing Sugar inside chroots. Tested: - inside chroot (no system bus): errors in log, neighbourhood shows buddies - on XO-1 (regular session, no NM): no errors, neighbourhood shows buddies, battery shown - on XO-1 (regular session, NM): no errors, neighbourhood shows buddies and networks, battery shown, disconnecting + automatic reconnect works, shutdown works Signed-off-by: Sascha Silbe --- (limited to 'extensions') diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py index 87db6d9..e1c3dab 100644 --- a/extensions/cpsection/network/model.py +++ b/extensions/cpsection/network/model.py @@ -65,8 +65,8 @@ def _restart_jabber(): ps.RestartServerConnection() def get_radio(): - bus = dbus.SystemBus() try: + bus = dbus.SystemBus() obj = bus.get_object(_NM_SERVICE, _NM_PATH) nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties') except dbus.DBusException: @@ -86,16 +86,16 @@ def set_radio(state): state : 'on/off' """ if state == 'on' or state == 1: - bus = dbus.SystemBus() try: + bus = dbus.SystemBus() obj = bus.get_object(_NM_SERVICE, _NM_PATH) nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties') except dbus.DBusException: raise ReadError('%s service not available' % _NM_SERVICE) nm_props.Set(_NM_IFACE, 'WirelessEnabled', True) elif state == 'off' or state == 0: - bus = dbus.SystemBus() try: + bus = dbus.SystemBus() obj = bus.get_object(_NM_SERVICE, _NM_PATH) nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties') except dbus.DBusException: -- cgit v0.9.1