Skip to content

Commit 1a56005

Browse files
authored
Prettier output for the wifi_test (bugfix) (canonical#1738)
Prettier output
1 parent 8335de3 commit 1a56005

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

providers/base/bin/wifi_nmcli_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,22 @@ def wait_for_connected(interface, essid):
191191
print_cmd(cmd)
192192
output = sp.check_output(shlex.split(cmd), universal_newlines=True)
193193
print(output)
194-
state, ssid = output.strip().splitlines()
194+
# if state is not connected, no ssid will be provided
195+
state, *ssid = output.strip().splitlines()
196+
ssid = next(iter(ssid), None)
195197

196198
if state.startswith("100") and ssid == essid:
197199
print("Reached connected state with ESSID: {}".format(essid))
200+
elif not state.startswith("100"):
201+
error_msg = "State is not connected: {}".format(state)
202+
raise SystemExit(error_msg)
198203
elif ssid != essid:
199204
error_msg = (
200205
"ERROR: did not reach connected state with ESSID: {}\n"
201206
"ESSID mismatch:\n Excepted:{}\n Actually:{}"
202207
).format(essid, ssid, essid)
203208
raise SystemExit(error_msg)
204-
elif not state.startswith("100"):
205-
error_msg = "State is not connected: {}".format(state)
206-
raise SystemExit(error_msg)
209+
207210
print()
208211

209212

0 commit comments

Comments
 (0)