summaryrefslogtreecommitdiff
path: root/bin
diff options
authorSylvain Pineau <sylvain.pineau@canonical.com>2015-06-02 10:22:55 +0200
committerSylvain Pineau <sylvain.pineau@canonical.com>2015-06-02 10:22:55 +0200
commit3704ad65a63b02e904be94b7d36fdc5598f1110a (patch)
tree59c2f6587e7d1f1acf8f312d65134a391505fce6 /bin
parent33f0f9b816ab430851932ccc7efc2e0444c8e3ec (diff)
providers:checkbox:bin:create_connection: Fix nmcli calls to comply with NM >= 0.9.10
Diffstat (limited to 'bin')
-rwxr-xr-xbin/create_connection15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/create_connection b/bin/create_connection
index 6f92859..767deb0 100755
--- a/bin/create_connection
+++ b/bin/create_connection
@@ -5,6 +5,11 @@ import os
import time
from subprocess import check_call, check_output, CalledProcessError
+try:
+ from subprocess import DEVNULL # >= python3.3
+except ImportError:
+ import os
+ DEVNULL = open(os.devnull, 'wb')
from uuid import uuid4
from argparse import ArgumentParser
@@ -127,8 +132,14 @@ baud=115200
def block_until_created(connection, retries, interval):
while retries > 0:
- nmcli_con_list = check_output(['nmcli', 'con', 'list'],
- universal_newlines=True)
+ try:
+ nmcli_con_list = check_output(['nmcli', 'con', 'list'],
+ stderr=DEVNULL,
+ universal_newlines=True)
+ except CalledProcessError:
+ nmcli_con_list = check_output(['nmcli', 'con', 'show'],
+ stderr=DEVNULL,
+ universal_newlines=True)
if connection in nmcli_con_list:
print("Connection %s registered" % connection)