about summary refs log tree commit diff
path: root/examples/python/dbus/list-connections.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/python/dbus/list-connections.py')
-rwxr-xr-xexamples/python/dbus/list-connections.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/examples/python/dbus/list-connections.py b/examples/python/dbus/list-connections.py
index 43a9c4e0..2e096b63 100755
--- a/examples/python/dbus/list-connections.py
+++ b/examples/python/dbus/list-connections.py
@@ -12,6 +12,7 @@ import dbus
 
 bus = dbus.SystemBus()
 
+
 def merge_secrets(proxy, config, setting_name):
     try:
         # returns a dict of dicts mapping name::setting, where setting is a dict
@@ -25,6 +26,7 @@ def merge_secrets(proxy, config, setting_name):
     except Exception as e:
         pass
 
+
 def dict_to_string(d, indent):
     # Try to trivially translate a dictionary's elements into nice string
     # formatting.
@@ -48,6 +50,7 @@ def dict_to_string(d, indent):
             dstr += "%s%s: %s\n" % (indent, key, str_val)
     return dstr
 
+
 def connection_to_string(config):
     # dump a connection configuration to a the console
     for setting_name in config:
@@ -66,29 +69,31 @@ def print_connections():
     # List each connection's name, UUID, and type
     for path in connection_paths:
         con_proxy = bus.get_object(service_name, path)
-        settings_connection = dbus.Interface(con_proxy, "org.freedesktop.NetworkManager.Settings.Connection")
+        settings_connection = dbus.Interface(
+            con_proxy, "org.freedesktop.NetworkManager.Settings.Connection"
+        )
         config = settings_connection.GetSettings()
 
         # Now get secrets too; we grab the secrets for each type of connection
         # (since there isn't a "get all secrets" call because most of the time
         # you only need 'wifi' secrets or '802.1x' secrets, not everything) and
         # merge that into the configuration data
-        merge_secrets(settings_connection, config, '802-11-wireless')
-        merge_secrets(settings_connection, config, '802-11-wireless-security')
-        merge_secrets(settings_connection, config, '802-1x')
-        merge_secrets(settings_connection, config, 'gsm')
-        merge_secrets(settings_connection, config, 'cdma')
-        merge_secrets(settings_connection, config, 'ppp')
+        merge_secrets(settings_connection, config, "802-11-wireless")
+        merge_secrets(settings_connection, config, "802-11-wireless-security")
+        merge_secrets(settings_connection, config, "802-1x")
+        merge_secrets(settings_connection, config, "gsm")
+        merge_secrets(settings_connection, config, "cdma")
+        merge_secrets(settings_connection, config, "ppp")
 
         # Get the details of the 'connection' setting
-        s_con = config['connection']
-        print("    name: %s" % s_con['id'])
-        print("    uuid: %s" % s_con['uuid'])
-        print("    type: %s" % s_con['type'])
+        s_con = config["connection"]
+        print("    name: %s" % s_con["id"])
+        print("    uuid: %s" % s_con["uuid"])
+        print("    type: %s" % s_con["type"])
         print("    ------------------------------------------")
         connection_to_string(config)
 
     print("")
 
-print_connections()
 
+print_connections()