8
from datetime import datetime
16
Check the time needed to reconnect an active WIFI connection
18
devices = subprocess.getoutput('nmcli dev')
19
match = re.search('(\w+)\s+802-11-wireless\s+connected', devices)
21
IFACE = match.group(1)
23
print("No active wifi connection detected", file=sys.stderr)
26
dev_status = subprocess.getoutput('nmcli -t -f devices,uuid con status')
27
match = re.search(IFACE+':(.*)', dev_status)
35
'nmcli dev disconnect iface %s' %IFACE,
36
stdout=open(os.devnull, 'w'),
37
stderr=subprocess.STDOUT,
41
start = datetime.now()
44
'nmcli con up uuid %s --timeout %s' %(uuid, TIMEOUT),
45
stdout=open(os.devnull, 'w'),
46
stderr=subprocess.STDOUT,
49
delta = datetime.now() - start
50
print('%.2f Seconds' %delta.total_seconds())
54
if __name__ == "__main__":