diff options
author | Sascha Silbe <sascha@silbe.org> | 2010-01-11 21:04:48 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha@silbe.org> | 2010-01-11 21:04:48 (GMT) |
commit | 08b278a01d1c96ff8a04c868acb3d744ce1092e4 (patch) | |
tree | e33510672c419eca966f17859ad8c2eba2b14d0a /extensions | |
parent | 8add5e0e288c09fd9b16da6e9024b571ec960fc9 (diff) |
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 <sascha@silbe.org>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/cpsection/network/model.py | 6 |
1 files changed, 3 insertions, 3 deletions
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: |