[Dextrose] [PATCH 1/5] Do not fail if NetworkManager is absent #2959

alsroot at sugarlabs.org alsroot at sugarlabs.org
Fri Oct 21 21:34:02 EDT 2011


From: Aleksey Lim <alsroot at activitycentral.org>

---
 src/jarabe/model/adhoc.py    |    3 ---
 src/jarabe/model/network.py  |    8 +++++++-
 src/jarabe/model/olpcmesh.py |    5 +----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/jarabe/model/adhoc.py b/src/jarabe/model/adhoc.py
index 647bd8e..b5a3557 100644
--- a/src/jarabe/model/adhoc.py
+++ b/src/jarabe/model/adhoc.py
@@ -137,9 +137,6 @@ class AdHocManager(gobject.GObject):
     def _update_state(self):
         self.emit('state-changed', self._current_channel, self._device_state)
 
-    def _have_configured_connections(self):
-        return len(network.get_settings().connections) > 0
-
     def autoconnect(self):
         """Start a timer which basically looks for 30 seconds of inactivity
         on the device, then does autoconnect to an Ad-hoc network.
diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index f265ae4..d58ad84 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -820,6 +820,9 @@ def get_settings():
 
 
 def find_connection_by_ssid(ssid):
+    if get_settings() is None:
+        return None
+
     connections = get_settings().connections
 
     for conn_index in connections:
@@ -961,6 +964,9 @@ def load_connections():
 
 
 def find_gsm_connection():
+    if get_settings() is None:
+        return None
+
     connections = get_settings().connections
 
     for connection in connections.values():
@@ -972,7 +978,7 @@ def find_gsm_connection():
 
 
 def have_wifi_connections():
-    return bool(get_settings().connections)
+    return get_settings() is not None and bool(get_settings().connections)
 
 
 def clear_wifi_connections():
diff --git a/src/jarabe/model/olpcmesh.py b/src/jarabe/model/olpcmesh.py
index f070100..e6562fa 100644
--- a/src/jarabe/model/olpcmesh.py
+++ b/src/jarabe/model/olpcmesh.py
@@ -82,7 +82,7 @@ class OlpcMeshManager(object):
         self._mesh_device_state = DEVICE_STATE_UNKNOWN
         self._eth_device_state = DEVICE_STATE_UNKNOWN
 
-        if self._have_configured_connections():
+        if network.have_wifi_connections():
             self._start_automesh_timer()
         else:
             self._start_automesh()
@@ -92,9 +92,6 @@ class OlpcMeshManager(object):
         eth_device_o = props.Get(_NM_OLPC_MESH_IFACE, 'Companion')
         return self._bus.get_object(_NM_SERVICE, eth_device_o)
 
-    def _have_configured_connections(self):
-        return len(network.get_settings().connections) > 0
-
     def _start_automesh_timer(self):
         """Start our timer system which basically looks for 10 seconds of
            inactivity on both devices, then starts automesh.
-- 
1.7.6.1



More information about the Dextrose mailing list