diff options
author | PMR <pmr@pmr-lander> | 2021-01-18 17:10:49 +0000 |
---|---|---|
committer | PMR <pmr@pmr-lander> | 2021-01-18 17:10:49 +0000 |
commit | c4dfa274687131fe84ffd11cc3243b52dc1fdcbb (patch) | |
tree | 93bdf192d1be2b469b8c38869513a0aff5732cf8 /bin | |
parent | 5054743bec999f7030a42a9fa6dc164792369958 (diff) | |
parent | 698a66ae3cf33a1130ae053e078e972b2b039613 (diff) |
Merge #395492 from ~sylvain-pineau/plainbox-provider-checkbox:wifi_nmcli_up_timeout
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/wifi_nmcli_test.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/bin/wifi_nmcli_test.py b/bin/wifi_nmcli_test.py index a6bbd8f..6f77376 100755 --- a/bin/wifi_nmcli_test.py +++ b/bin/wifi_nmcli_test.py @@ -17,11 +17,23 @@ import subprocess as sp import sys import time +from distutils.version import LooseVersion from gateway_ping_test import ping print = functools.partial(print, flush=True) +def legacy_nmcli(): + cmd = "nmcli -v" + output = sp.check_output(cmd, shell=True) + version = LooseVersion(output.strip().split()[-1].decode()) + # check if using the 16.04 nmcli because of this bug + # https://bugs.launchpad.net/plano/+bug/1896806 + if version < LooseVersion("1.9.9"): + return True + return False + + def print_head(txt): print("##", txt) @@ -159,7 +171,10 @@ def open_connection(args): # Make sure the connection is brought up cmd = "nmcli c up TEST_CON" print_cmd(cmd) - sp.call(cmd, shell=True) + try: + sp.call(cmd, shell=True, timeout=200 if legacy_nmcli() else None) + except sp.TimeoutExpired: + print("Connection activation failed\n") print() print_head("Ensure interface is connected") @@ -206,7 +221,10 @@ def secured_connection(args): # Make sure the connection is brought up cmd = "nmcli c up TEST_CON" print_cmd(cmd) - sp.call(cmd, shell=True) + try: + sp.call(cmd, shell=True, timeout=200 if legacy_nmcli() else None) + except sp.TimeoutExpired: + print("Connection activation failed\n") print() print_head("Ensure interface is connected") |