mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
network: Minor fix when getting connection and styling
This commit is contained in:
parent
333599ba24
commit
03049b666a
@ -91,23 +91,22 @@ def get_connection_list():
|
|||||||
def get_connection(connection_uuid):
|
def get_connection(connection_uuid):
|
||||||
"""Return connection with matching uuid.
|
"""Return connection with matching uuid.
|
||||||
|
|
||||||
Raise ConnectionNotFound if a connection with that uuid is not found.
|
Raise ConnectionNotFound if a connection with that uuid is not
|
||||||
|
found.
|
||||||
"""
|
"""
|
||||||
client = nm.Client.new(None)
|
client = nm.Client.new(None)
|
||||||
try:
|
connection = client.get_connection_by_uuid(connection_uuid)
|
||||||
connection = client.get_connection_by_uuid(connection_uuid)
|
if not connection:
|
||||||
if not connection:
|
|
||||||
raise ConnectionNotFound(connection_uuid)
|
|
||||||
except KeyError:
|
|
||||||
raise ConnectionNotFound(connection_uuid)
|
raise ConnectionNotFound(connection_uuid)
|
||||||
|
|
||||||
return connection
|
return connection
|
||||||
|
|
||||||
|
|
||||||
def get_active_connection(connection_uuid):
|
def get_active_connection(connection_uuid):
|
||||||
"""Returns active connection with matching uuid.
|
"""Return active connection with matching UUID.
|
||||||
|
|
||||||
Raise ConnectionNotFound if a connection with that uuid is not found.
|
Raise ConnectionNotFound if a connection with that uuid is not
|
||||||
|
found.
|
||||||
"""
|
"""
|
||||||
connections = nm.Client.new(None).get_active_connections()
|
connections = nm.Client.new(None).get_active_connections()
|
||||||
connections = {connection.get_uuid(): connection
|
connections = {connection.get_uuid(): connection
|
||||||
@ -175,7 +174,8 @@ def _update_ethernet_settings(connection, connection_uuid, name, zone,
|
|||||||
|
|
||||||
def add_ethernet_connection(name, zone, ipv4_method, ipv4_address):
|
def add_ethernet_connection(name, zone, ipv4_method, ipv4_address):
|
||||||
"""Add an automatic ethernet connection in network manager.
|
"""Add an automatic ethernet connection in network manager.
|
||||||
Returns the UUID for the connection.
|
|
||||||
|
Return the UUID for the connection.
|
||||||
"""
|
"""
|
||||||
connection_uuid = str(uuid.uuid4())
|
connection_uuid = str(uuid.uuid4())
|
||||||
connection = _update_ethernet_settings(
|
connection = _update_ethernet_settings(
|
||||||
@ -231,6 +231,7 @@ def _update_wifi_settings(connection, connection_uuid, name, zone, ssid, mode,
|
|||||||
def add_wifi_connection(name, zone, ssid, mode, auth_mode, passphrase,
|
def add_wifi_connection(name, zone, ssid, mode, auth_mode, passphrase,
|
||||||
ipv4_method, ipv4_address):
|
ipv4_method, ipv4_address):
|
||||||
"""Add an automatic Wi-Fi connection in network manager.
|
"""Add an automatic Wi-Fi connection in network manager.
|
||||||
|
|
||||||
Return the UUID for the connection.
|
Return the UUID for the connection.
|
||||||
"""
|
"""
|
||||||
connection_uuid = str(uuid.uuid4())
|
connection_uuid = str(uuid.uuid4())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user