Skip to content

Commit 6815cea

Browse files
authored
Merge pull request #12 from bernhardkaindl/add-wifi-conn-fix
add-wifi-psk-connection: check return value of example
2 parents dcb2b06 + 7e32042 commit 6815cea

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

examples/async/add-wifi-psk-connection-async.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from sdbus_async.networkmanager import NetworkManagerConnectionProperties
5656

5757

58-
async def add_wifi_psk_connection_profile_async(args: Namespace) -> str:
58+
async def add_wifi_psk_connection_async(args: Namespace) -> str:
5959
"""Add a temporary (not yet saved) network connection profile
6060
:param Namespace args: autoconnect, conn_id, psk, save, ssid, uuid
6161
:return: dbus connection path of the created connection profile
@@ -118,6 +118,8 @@ async def add_wifi_psk_connection_profile_async(args: Namespace) -> str:
118118
p.add_argument("--save", dest="save", action="store_true", help="Save")
119119
args = p.parse_args()
120120
sdbus.set_default_bus(sdbus.sd_bus_open_system())
121-
connection_dpath = asyncio.run(add_wifi_psk_connection_profile_async(args))
122-
print(f"Path of the new connection: {connection_dpath}")
123-
print(f"UUID of the new connection: {args.uuid}")
121+
if connection_dpath := asyncio.run(add_wifi_psk_connection_async(args)):
122+
print(f"Path of the new connection: {connection_dpath}")
123+
print(f"UUID of the new connection: {args.uuid}")
124+
else:
125+
print("Error: No new connection created.")

examples/block/add-wifi-psk-connection.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
from sdbus_block.networkmanager import NetworkManagerConnectionProperties
5555

5656

57-
def add_wifi_psk_connection_profile(args: Namespace) -> str:
57+
def add_wifi_psk_connection(args: Namespace) -> str:
5858
"""Add a temporary (not yet saved) network connection profile
5959
:param Namespace args: autoconnect, conn_id, psk, save, ssid, uuid
6060
:return: dbus connection path of the created connection profile
@@ -117,6 +117,8 @@ def add_wifi_psk_connection_profile(args: Namespace) -> str:
117117
p.add_argument("--save", dest="save", action="store_true", help="Save")
118118
args = p.parse_args()
119119
sdbus.set_default_bus(sdbus.sd_bus_open_system())
120-
connection_dpath = add_wifi_psk_connection_profile(args)
121-
print(f"Path of the new connection: {connection_dpath}")
122-
print(f"UUID of the new connection: {args.uuid}")
120+
if connection_dpath := add_wifi_psk_connection(args):
121+
print(f"Path of the new connection: {connection_dpath}")
122+
print(f"UUID of the new connection: {args.uuid}")
123+
else:
124+
print("Error: No new connection created.")

0 commit comments

Comments
 (0)