Merge lp:~ezrareeves/groundcontrol/nm-fail into lp:groundcontrol

Proposed by Ezra Reeves
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ezrareeves/groundcontrol/nm-fail
Merge into: lp:groundcontrol
Diff against target: 40 lines (+15/-3)
1 file modified
GroundControl/base.py (+15/-3)
To merge this branch: bzr merge lp:~ezrareeves/groundcontrol/nm-fail
Reviewer Review Type Date Requested Status
Ground Controllers Pending
Review via email: mp+22026@code.launchpad.net

Description of the change

If NetworkManager is not running GC will assume that it is always connected.

Implemented by searching current dbus objects for NM before trying to use it.

Because of the current authentication issues with GC I have not been able to test it while connected.

To post a comment you must log in.
Revision history for this message
Łukasz Jernaś (deejay1) wrote :

Looks good to me

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GroundControl/base.py'
2--- GroundControl/base.py 2010-03-01 06:04:07 +0000
3+++ GroundControl/base.py 2010-03-24 14:20:32 +0000
4@@ -130,21 +130,33 @@
5 NM_STATE_DISCONNECTED = 4
6 NM_LOCATION = '/org/freedesktop/NetworkManager'
7 NM_OBJNAME = 'org.freedesktop.NetworkManager'
8+DBUS_LOCATION = '/org/freedesktop/DBus'
9+DBUS_OBJNAME = 'org.freedesktop.DBus'
10
11 from dbus.mainloop.glib import DBusGMainLoop
12
13 DBusGMainLoop(set_as_default=True)
14
15 bus = dbus.SystemBus()
16-nm = bus.get_object(NM_OBJNAME, NM_LOCATION)
17+dbus_objects = dbus.Interface(bus.get_object(DBUS_OBJNAME, DBUS_LOCATION),
18+ DBUS_OBJNAME).ListNames()
19+
20+running_NM = True if NM_OBJNAME in dbus_objects else False
21+
22+if running_NM:
23+ nm = bus.get_object(NM_OBJNAME, NM_LOCATION)
24
25 def is_online():
26 """Return true if we're online"""
27- return nm.state() == NM_STATE_CONNECTED
28+ if not running_NM:
29+ return True #if NM is not running assume always connected
30+ else:
31+ return nm.state() == NM_STATE_CONNECTED
32
33 def set_online_changed(method):
34 """Tie a method to a network manager status change"""
35- bus.add_signal_receiver(method, 'StateChanged',
36+ if running_NM :
37+ bus.add_signal_receiver(method, 'StateChanged',
38 NM_OBJNAME, NM_OBJNAME, NM_LOCATION)
39
40 def save_config(name=CONFIG_NAME, yaml=GC_CONFIG):

Subscribers

People subscribed via source and target branches