Disconnect network using cNetworkManager Python library
mvidner at suse.cz
Mon Jan 23 09:05:17 PST 2012
On Mon, Jan 23, 2012 at 03:46:16PM +0100, Olivier Deckmyn wrote:
> class Wifi(object):
> def connect(self, ssid, security="open", password=None):
> "Connects to given Wifi network"
> c=None # connection settings
> us = NetworkManagerUserSettings()
NetworkManagerUserSettings is a server, not a client. (It's a design
quirk of NM which was eliminated in NM 0.9)
You should create only one for the daemon, not for each conection
> def change_network_settings():
> if change is not None:
> print "DISCONNECT"
> print "CHANGE SETTINGS"
> if wifi is not None:
> print "SWITCHING TO %s"%ssid
> Wifi().connect(ssid, security, password)
> return True
Please be warned that cnetworkmanager is obsolete as upstream now
includes its own CLI, nmcli (written in C, since about NM 0.8.1). I
haven't updated cnetworkmanager for the API changes of NM 0.9.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: not available
More information about the dbus