From 021cb0c4befeb7b24d7a36c794c3a6d6ab067997 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@activitycentral.org>
Date: Mon, 11 Jul 2011 11:45:58 +0000
Subject: [PATCH sugar] Do not fail if NetworkManager is absent #2959
---
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
|
b
|
class AdHocManager(gobject.GObject): |
137 | 137 | def _update_state(self): |
138 | 138 | self.emit('state-changed', self._current_channel, self._device_state) |
139 | 139 | |
140 | | def _have_configured_connections(self): |
141 | | return len(network.get_settings().connections) > 0 |
142 | | |
143 | 140 | def autoconnect(self): |
144 | 141 | """Start a timer which basically looks for 30 seconds of inactivity |
145 | 142 | 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
|
b
|
def get_settings(): |
820 | 820 | |
821 | 821 | |
822 | 822 | def find_connection_by_ssid(ssid): |
| 823 | if get_settings() is None: |
| 824 | return None |
| 825 | |
823 | 826 | connections = get_settings().connections |
824 | 827 | |
825 | 828 | for conn_index in connections: |
… |
… |
def load_connections(): |
961 | 964 | |
962 | 965 | |
963 | 966 | def find_gsm_connection(): |
| 967 | if get_settings() is None: |
| 968 | return None |
| 969 | |
964 | 970 | connections = get_settings().connections |
965 | 971 | |
966 | 972 | for connection in connections.values(): |
… |
… |
def find_gsm_connection(): |
972 | 978 | |
973 | 979 | |
974 | 980 | def have_wifi_connections(): |
975 | | return bool(get_settings().connections) |
| 981 | return get_settings() is not None and bool(get_settings().connections) |
976 | 982 | |
977 | 983 | |
978 | 984 | def clear_wifi_connections(): |
diff --git a/src/jarabe/model/olpcmesh.py b/src/jarabe/model/olpcmesh.py
index f070100..e6562fa 100644
a
|
b
|
class OlpcMeshManager(object): |
82 | 82 | self._mesh_device_state = DEVICE_STATE_UNKNOWN |
83 | 83 | self._eth_device_state = DEVICE_STATE_UNKNOWN |
84 | 84 | |
85 | | if self._have_configured_connections(): |
| 85 | if network.have_wifi_connections(): |
86 | 86 | self._start_automesh_timer() |
87 | 87 | else: |
88 | 88 | self._start_automesh() |
… |
… |
class OlpcMeshManager(object): |
92 | 92 | eth_device_o = props.Get(_NM_OLPC_MESH_IFACE, 'Companion') |
93 | 93 | return self._bus.get_object(_NM_SERVICE, eth_device_o) |
94 | 94 | |
95 | | def _have_configured_connections(self): |
96 | | return len(network.get_settings().connections) > 0 |
97 | | |
98 | 95 | def _start_automesh_timer(self): |
99 | 96 | """Start our timer system which basically looks for 10 seconds of |
100 | 97 | inactivity on both devices, then starts automesh. |