mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 13:38:43 +02:00
example: simplify get-active-connections.py by using ID and Type properties
This commit is contained in:
parent
ee6f684f0a
commit
3e44e7a9f8
1 changed files with 3 additions and 16 deletions
|
|
@ -21,27 +21,14 @@
|
||||||
|
|
||||||
# This example lists currently active connections
|
# This example lists currently active connections
|
||||||
|
|
||||||
main_loop = None
|
from gi.repository import GLib, NMClient
|
||||||
|
|
||||||
from gi.repository import GLib, NetworkManager, NMClient
|
if __name__ == "__main__":
|
||||||
|
|
||||||
def connections_read(settings):
|
|
||||||
client = NMClient.Client.new()
|
client = NMClient.Client.new()
|
||||||
acons = client.get_active_connections()
|
acons = client.get_active_connections()
|
||||||
for ac in acons:
|
for ac in acons:
|
||||||
rem_con = settings.get_connection_by_path(ac.get_connection())
|
print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type())
|
||||||
c_type = rem_con.get_setting_connection().get_connection_type()
|
|
||||||
print "%s (%s) - %s" % (rem_con.get_id(), ac.get_uuid(), c_type)
|
|
||||||
if len(acons) == 0:
|
if len(acons) == 0:
|
||||||
print "No active connections"
|
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()
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue