Skip to content

Commit 5f480c6

Browse files
authored
Merge pull request #77 from hkhateb/fix_get_connections_by_id_exception
Fix NetworkManagerSettings.get_connections_by_id not using the bus it was initialized with Thank you @hkhateb
2 parents ff0567f + 4b94e8f commit 5f480c6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

sdbus_async/networkmanager/objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def __init__(self, bus: Optional[SdBus] = None) -> None:
159159
NETWORK_MANAGER_SERVICE_NAME,
160160
'/org/freedesktop/NetworkManager/Settings',
161161
bus)
162+
self._nm_used_bus = bus
162163

163164
async def get_connections_by_id(self, connection_id: str) -> List[str]:
164165
"""Helper method to get a list of connection profile paths
@@ -171,7 +172,7 @@ async def get_connections_by_id(self, connection_id: str) -> List[str]:
171172
connection_paths_with_matching_id = []
172173
connection_paths: List[str] = await self.connections
173174
for connection_path in connection_paths:
174-
settings = NetworkConnectionSettings(connection_path)
175+
settings = NetworkConnectionSettings(connection_path, self._nm_used_bus)
175176
settings_properites = await settings.get_settings()
176177
# settings_properites["connection"]["id"][1] gives the id value:
177178
if settings_properites["connection"]["id"][1] == connection_id:

sdbus_block/networkmanager/objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def __init__(self, bus: Optional[SdBus] = None) -> None:
154154
NETWORK_MANAGER_SERVICE_NAME,
155155
'/org/freedesktop/NetworkManager/Settings',
156156
bus)
157+
self._nm_used_bus = bus
157158

158159
def get_connections_by_id(self, connection_id: str) -> List[str]:
159160
"""Helper method to get a list of connection profile paths
@@ -165,7 +166,7 @@ def get_connections_by_id(self, connection_id: str) -> List[str]:
165166
"""
166167
connection_paths_with_matching_id = []
167168
for connection_path in self.connections:
168-
profile = NetworkConnectionSettings(connection_path)
169+
profile = NetworkConnectionSettings(connection_path, self._nm_used_bus)
169170
# profile.get_settings()["connection"]["id"][1] gives the id value:
170171
if profile.get_settings()["connection"]["id"][1] == connection_id:
171172
connection_paths_with_matching_id.append(connection_path)

0 commit comments

Comments
 (0)