/usr/lib/2013.com.canonical.certification:checkbox/bin/wifi_time2reconnect is in plainbox-provider-checkbox 0.4-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #!/usr/bin/env python3
import os
import re
import sys
import time
import subprocess
from datetime import datetime
IFACE = None
TIMEOUT = 30
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)
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')
match = re.search(IFACE+':(.*)', dev_status)
uuid = None
if match:
uuid = match.group(1)
else:
return 1
subprocess.call(
'nmcli dev disconnect iface %s' %IFACE,
stdout=open(os.devnull, 'w'),
stderr=subprocess.STDOUT,
shell=True)
time.sleep(2)
start = datetime.now()
subprocess.call(
'nmcli con up uuid %s --timeout %s' %(uuid, TIMEOUT),
stdout=open(os.devnull, 'w'),
stderr=subprocess.STDOUT,
shell=True)
delta = datetime.now() - start
print('%.2f Seconds' %delta.total_seconds())
return 0
if __name__ == "__main__":
sys.exit(main())
|