diff options
| author | Michael Biebl <biebl@debian.org> | 2020-10-05 22:28:16 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-10-05 22:28:16 +0200 |
| commit | 47a2114d6f697a31d84c8874c49e94dd04119d75 (patch) | |
| tree | e3022686ff1956d7f17f1f7cdf7022ce980b7a5c /examples/python/dbus/get-active-connection-uuids.py | |
| parent | 9d722f3d3492e31c0b3e4bcba603ffd65309c621 (diff) | |
| parent | aafc1dbe4712c86189bbc1d4d54ad8cb4c69be7e (diff) | |
Update upstream source from tag 'upstream/1.27.90'
Update to upstream version '1.27.90' with Debian dir 72a0791efa5966be1724a82dfcac90f6cd22bd1b
Diffstat (limited to 'examples/python/dbus/get-active-connection-uuids.py')
| -rwxr-xr-x | examples/python/dbus/get-active-connection-uuids.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/examples/python/dbus/get-active-connection-uuids.py b/examples/python/dbus/get-active-connection-uuids.py index e138ce60..3e80b603 100755 --- a/examples/python/dbus/get-active-connection-uuids.py +++ b/examples/python/dbus/get-active-connection-uuids.py @@ -6,9 +6,8 @@ import dbus -# This example takes a device interface name as a parameter and tells -# NetworkManager to disconnect that device, closing down any network -# connection it may have +# This example lists all of the active connections +# the system is connected to and prints it out bus = dbus.SystemBus() @@ -16,23 +15,15 @@ bus = dbus.SystemBus() m_proxy = bus.get_object( "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager" ) -manager = dbus.Interface(m_proxy, "org.freedesktop.NetworkManager") mgr_props = dbus.Interface(m_proxy, "org.freedesktop.DBus.Properties") -s_proxy = bus.get_object( - "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings" -) -settings = dbus.Interface(s_proxy, "org.freedesktop.NetworkManager.Settings") - -# Find the device the user wants to disconnect +# Find all active connections active = mgr_props.Get("org.freedesktop.NetworkManager", "ActiveConnections") + for a in active: a_proxy = bus.get_object("org.freedesktop.NetworkManager", a) - # Get the UUID directly; apps could use this to perform certain operations - # based on which network you're connected too a_props = dbus.Interface(a_proxy, "org.freedesktop.DBus.Properties") - uuid = a_props.Get("org.freedesktop.NetworkManager.Connection.Active", "Uuid") # Grab the connection object path so we can get all the connection's settings connection_path = a_props.Get( @@ -45,7 +36,11 @@ for a in active: settings = connection.GetSettings() print( "%s (%s) - %s" - % (settings["connection"]["id"], uuid, settings["connection"]["type"]) + % ( + settings["connection"]["id"], + settings["connection"]["uuid"], + settings["connection"]["type"], + ) ) if len(active) == 0: |