Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhpeters committed Sep 18, 2019
1 parent 93ecd78 commit d07c276
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions eduvpn/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def delete_provider(uuid): # type: (str) -> None
raise


def connect_provider(uuid): # type: (str) -> None
def connect_provider(uuid): # type: (str) -> Any
"""
Enable the network manager configuration by its UUID
Expand All @@ -156,8 +156,7 @@ def connect_provider(uuid): # type: (str) -> None

try:
connection = NetworkManager.Settings.GetConnectionByUuid(uuid) # type: ignore
return NetworkManager.NetworkManager.ActivateConnection(connection,
"/", "/") # type: ignore
return NetworkManager.ActivateConnection(connection, "/", "/") # type: ignore
except DBusException as e: # type: ignore
raise EduvpnException(e)

Expand All @@ -174,8 +173,8 @@ def list_active(): # type: () -> list
return []

try:
active = NetworkManager.NetworkManager.ActiveConnections
return [a for a in active if NetworkManager.Settings.
active = NetworkManager.ActiveConnections # type: ignore
return [a for a in active if NetworkManager.Settings. # type: ignore
GetConnectionByUuid(a.Uuid).GetSettings() # type: ignore
['connection']['type'] == 'vpn'] # type: ignore
except DBusException:
Expand All @@ -189,8 +188,8 @@ def disconnect_all(): # type: () -> Any
if not have_dbus():
return []

for active in NetworkManager.NetworkManager.ActiveConnections:
conn = NetworkManager.Settings.GetConnectionByUuid(active.Uuid)
for active in NetworkManager.ActiveConnections: # type: ignore
conn = NetworkManager.Settings.GetConnectionByUuid(active.Uuid) # type: ignore
if conn.GetSettings()['connection']['type'] == 'vpn': # type: ignore
disconnect_provider(active.Uuid) # type: ignore

Expand All @@ -207,7 +206,7 @@ def disconnect_provider(uuid): # type: (str) -> None
if not have_dbus():
raise EduvpnException("No DBus daemon running")

conns = [i for i in NetworkManager.NetworkManager.ActiveConnections
conns = [i for i in NetworkManager.ActiveConnections # type: ignore
if i.Uuid == uuid]
if len(conns) == 0: # type: ignore
raise EduvpnException("no active connection found"
Expand Down Expand Up @@ -248,7 +247,7 @@ def update_config_provider(meta, config_dict): # type: (Metadata, dict) -> None
username=meta.username)

if have_dbus():
connection = NetworkManager.Settings.GetConnectionByUuid(meta.uuid)
connection = NetworkManager.Settings.GetConnectionByUuid(meta.uuid) # type: ignore
old_settings = connection.GetSettings()
nm_config['vpn']['data'].update({'cert': (old_settings['vpn']['data']['cert']),
'key': (old_settings['vpn']['data']['key'])}) # type: ignore
Expand Down

0 comments on commit d07c276

Please sign in to comment.