[Sugar-devel] [PATCH v2] Simple NetworkManager-0.9 port

Simon Schampijer simon at schampijer.de
Mon Nov 14 08:39:25 EST 2011


El 11/11/11 18:17, Daniel Drake escribió:
> Adapt sugar to NetworkManager-0.9 API changes.
>
> The major change here is the removal of the user-level connections
> mechanism; instead of storing connection information in Sugar,
> NetworkManager now Manages our Networks for us.
>
> However, some level of interfacing/monitoring NM is now needed,
> implemented with the Connections and Connection classes in
> jarabe.model.network.
>
> If found, connections in sugar's connections.cfg are automatically
> migrated, and then connections.cfg is deleted. Similarly, if modem
> connection details are found in gconf, they are migrated into NM
> and then the gconf keys are unset.
>
> The existing network code is far from perfect and actually quite messy.
> In this port I've tried not to make fundamental changes to improve this,
> in order to keep task complexity down and aid review.
> In the medium term I do plan to improve this code, by moving it to
> use gobject-introspection on libnm, and rewriting/restructuring at the
> same time. By letting libnm do most of the work for us, this layer can
> be greatly simplified. However, libnm and gobject-introspection
> improvements are needed first, which I will continue to work on.
>
> Modem PUK configuration has been removed as NetworkManager no longer
> has configuration for this. It hasn't been used (and was marked
> deprecated) throughout the NM-0.8 release series.
> ---
>   data/sugar.schemas.in                            |   24 +-
>   extensions/cpsection/modemconfiguration/model.py |  106 ++--
>   extensions/cpsection/modemconfiguration/view.py  |  207 ++-----
>   extensions/cpsection/network/model.py            |   14 +-
>   extensions/deviceicon/network.py                 |  179 +++---
>   src/jarabe/desktop/keydialog.py                  |   32 +-
>   src/jarabe/desktop/meshbox.py                    |   60 +-
>   src/jarabe/desktop/networkviews.py               |  169 ++---
>   src/jarabe/model/adhoc.py                        |  115 ++--
>   src/jarabe/model/network.py                      |  754 +++++++++++-----------
>   src/jarabe/model/olpcmesh.py                     |  159 +++--
>   11 files changed, 844 insertions(+), 975 deletions(-)
>
> v2: handle review comments from Simon and Sascha's Oct 24 mail. Only non-minor
> resulting change is a refactoring of modem setting handling so that undo
> is supported again.
>

[...]

> diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py
> index 916ce8c..fb8291d 100644
> --- a/extensions/cpsection/network/model.py
> +++ b/extensions/cpsection/network/model.py
 >
> @@ -112,11 +112,21 @@ def clear_registration():
>   def clear_networks():
>       """Clear saved passwords and network configurations.
>       """
> -    network.clear_wifi_connections()
> +    try:
> +        connections = network.get_connections()
> +    except dbus.DBusException:
> +        logging.debug('NetworkManager not available')
> +        return
> +    connections.clear()

We are missing the import of 'logging' here.

>   def have_networks():
> -    return network.have_wifi_connections()
> +    try:
> +        connections = network.get_connections()
> +    except dbus.DBusException:
> +        logging.debug('NetworkManager not available')
> +        return False
> +    return len(network.get_connections().get_list())>  0

- we are missing the import of 'logging' here
- you are calling 'network.get_connections' twice. The second one can be 
'connections.get_list()'

Regards,
    Simon


More information about the Sugar-devel mailing list