Skip to content

Fix exception in NetworkManagerSettings.get_connections_by_id #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdbus_async/networkmanager/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def __init__(self, bus: Optional[SdBus] = None) -> None:
NETWORK_MANAGER_SERVICE_NAME,
'/org/freedesktop/NetworkManager/Settings',
bus)
self._nm_used_bus = bus

async def get_connections_by_id(self, connection_id: str) -> List[str]:
"""Helper method to get a list of connection profile paths
Expand All @@ -171,7 +172,7 @@ async def get_connections_by_id(self, connection_id: str) -> List[str]:
connection_paths_with_matching_id = []
connection_paths: List[str] = await self.connections
for connection_path in connection_paths:
settings = NetworkConnectionSettings(connection_path)
settings = NetworkConnectionSettings(connection_path, self._nm_used_bus)
settings_properites = await settings.get_settings()
# settings_properites["connection"]["id"][1] gives the id value:
if settings_properites["connection"]["id"][1] == connection_id:
Expand Down
3 changes: 2 additions & 1 deletion sdbus_block/networkmanager/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def __init__(self, bus: Optional[SdBus] = None) -> None:
NETWORK_MANAGER_SERVICE_NAME,
'/org/freedesktop/NetworkManager/Settings',
bus)
self._nm_used_bus = bus

def get_connections_by_id(self, connection_id: str) -> List[str]:
"""Helper method to get a list of connection profile paths
Expand All @@ -165,7 +166,7 @@ def get_connections_by_id(self, connection_id: str) -> List[str]:
"""
connection_paths_with_matching_id = []
for connection_path in self.connections:
profile = NetworkConnectionSettings(connection_path)
profile = NetworkConnectionSettings(connection_path, self._nm_used_bus)
# profile.get_settings()["connection"]["id"][1] gives the id value:
if profile.get_settings()["connection"]["id"][1] == connection_id:
connection_paths_with_matching_id.append(connection_path)
Expand Down