diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-03-03 15:29:10 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-03-05 16:17:13 +0100 |
commit | 3e44e7a9f8984a736caeedfa022a43bc12f0148e (patch) | |
tree | 5f975a511e38cf61b065fcf9e704ff440bc3ae6c /examples | |
parent | ee6f684f0ac52500601ecb9badff38f43e69014f (diff) | |
download | NetworkManager-3e44e7a9f8984a736caeedfa022a43bc12f0148e.tar.gz |
example: simplify get-active-connections.py by using ID and Type properties
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/python/gi/get-active-connections.py | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py index 13646acfaf..13f0b0310e 100755 --- a/examples/python/gi/get-active-connections.py +++ b/examples/python/gi/get-active-connections.py @@ -21,27 +21,14 @@ # This example lists currently active connections -main_loop = None +from gi.repository import GLib, NMClient -from gi.repository import GLib, NetworkManager, NMClient - -def connections_read(settings): +if __name__ == "__main__": client = NMClient.Client.new() acons = client.get_active_connections() for ac in acons: - rem_con = settings.get_connection_by_path(ac.get_connection()) - c_type = rem_con.get_setting_connection().get_connection_type() - print "%s (%s) - %s" % (rem_con.get_id(), ac.get_uuid(), c_type) + print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type()) if len(acons) == 0: print "No active connections" - main_loop.quit() - -if __name__ == "__main__": - main_loop = GLib.MainLoop() - settings = NMClient.RemoteSettings.new(None); - # connections are read asynchronously, so we need to wait for the - # settings object to tell us that it's read all connections - settings.connect("connections-read", connections_read) - main_loop.run() |