[Sugar-devel] [PATCH sugar] Don't break if we may not own NetworkManagerUserSettings
Marco Pesenti Gritti
marco at marcopg.org
Mon Jul 19 15:20:08 EDT 2010
On 14 Jul 2010, at 14:11, Sascha Silbe <sascha-pgp at silbe.org> wrote:
> diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
> index 3a949da..623abca 100644
> --- a/src/jarabe/model/network.py
> +++ b/src/jarabe/model/network.py
> @@ -566,11 +566,19 @@ def get_settings():
> _nm_settings = NMSettings()
> except dbus.DBusException:
> logging.exception('Cannot create the UserSettings service.')
> - load_connections()
> + _nm_settings = 'unavailable'
> + else:
> + load_connections()
> + if _nm_settings == 'unavailable':
> + return None
> return _nm_settings
Assigning a string is a bit weird. I'd rather use a separate boolean or add a DummyNMSettings class which would also avoid None checks all over the place.
> def find_connection_by_ssid(ssid):
> - connections = get_settings().connections
> + settings = get_settings()
> + if settings is None:
> + return None
> +
> + connections = settings.connections
If we keep the None checks it would probably be worth to add a get_connections function to avoid duplication.
The add_connection function seems to also depend on nm settings being available.
A comment about in which conditions nm settings might not be available would be useful.
Thanks,
Marco
More information about the Sugar-devel
mailing list