From 3704ad65a63b02e904be94b7d36fdc5598f1110a Mon Sep 17 00:00:00 2001 From: Sylvain Pineau Date: Tue, 2 Jun 2015 10:22:55 +0200 Subject: providers:checkbox:bin:create_connection: Fix nmcli calls to comply with NM >= 0.9.10 --- bin/create_connection | 15 +++++++++++++-- 1 file 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) -- cgit v1.2.3