all: reformat python files with python black
Part of !537. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
This commit is contained in:

committed by
Thomas Haller

parent
b6febb0fd0
commit
be822b52e6
@@ -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()
|
||||
|
Reference in New Issue
Block a user