summaryrefslogtreecommitdiff
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
commit6bed32c2455652168e99559e304cdd64e3c4cb9a (patch)
treecb239fcf30ad7e525b5bc81c07cf6cc7c003a57f
parente0405b10b3bd07f83c09847450e895baa30ffe4f (diff)
providers:checkbox:bin:wifi_time2reconnect: Fix nmcli calls to comply with NM >= 0.9.10
-rwxr-xr-xbin/wifi_time2reconnect18
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/wifi_time2reconnect b/bin/wifi_time2reconnect
index bfaa2ce..d4ae2c0 100755
--- a/bin/wifi_time2reconnect
+++ b/bin/wifi_time2reconnect
@@ -6,6 +6,11 @@ import sys
import time
import subprocess
from datetime import datetime
+try:
+ from subprocess import DEVNULL # >= python3.3
+except ImportError:
+ import os
+ DEVNULL = open(os.devnull, 'wb')
IFACE = None
TIMEOUT = 30
@@ -16,14 +21,23 @@ def main():
Check the time needed to reconnect an active WIFI connection
"""
devices = subprocess.getoutput('nmcli dev')
- match = re.search('(\w+)\s+802-11-wireless\s+connected', devices)
+ match = re.search('(\w+)\s+(802-11-wireless|wifi)\s+connected', devices)
if match:
IFACE = match.group(1)
else:
print("No active wifi connection detected", file=sys.stderr)
return 1
- dev_status = subprocess.getoutput('nmcli -t -f devices,uuid con status')
+ try:
+ dev_status = subprocess.check_output(
+ ['nmcli', '-t', '-f', 'devices,uuid', 'con', 'status'],
+ stderr=DEVNULL,
+ universal_newlines=True)
+ except subprocess.CalledProcessError:
+ dev_status = subprocess.check_output(
+ ['nmcli', '-t', '-f', 'device,uuid', 'con', 'show'],
+ stderr=DEVNULL,
+ universal_newlines=True)
match = re.search(IFACE+':(.*)', dev_status)
uuid = None
if match: