I found this code to work well - turn wifi on, wait until connected, allow a timeout:
Code:
sp = subprocess.Popen(['lipc-set-prop', 'com.lab126.cmd', 'wirelessEnable', '1'], stdout=subprocess.PIPE)
wifi = 'OFF'
loop = 0
while loop < 40:sp = subprocess.Popen(['lipc-get-prop', 'com.lab126.wifid', 'cmState'], stdout=subprocess.PIPE)
response, _ = sp.communicate()
if response.find("CONNECTED") > -1:
wifi = 'ON'
break
else:
loop +=1
sleep(1.5)