print"Error execting command to kill process "+name
sys.exit(1)
print"Out = "+out
defstart_ue():
#print 'Enter your commands below.\r\nInsert "exit" to leave the application.'
print'Killing old iperf/ping sessions'
kill_processes('iperf')
kill_processes('ping')
print"Turning off airplane mode"
os.system('sudo -E adb devices')
os.system('sudo -E adb -s '+device_id+' shell \"settings put global airplane_mode_on 0; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false\"')
error=error+' In function: '+sys._getframe().f_code.co_name+': *** Caught exception: '+str(e.__class__)+" : "+str(e)
error=error+traceback.format_exc()
printerror
defstop_ue():
print"Turning on airplane mode"
os.system('sudo adb devices')
os.system('sudo adb -s '+device_id+' shell \"settings put global airplane_mode_on 1; am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true\" ')
print"Killing iperf/ping sessions"
kill_processes('iperf')
kill_processes('ping')
i=1
gw='192.172.0.1'
whilei<len(sys.argv):
arg=sys.argv[i]
ifarg=='--start-ue':
start_ue()
elifarg=='--stop-ue':
stop_ue()
elifarg=='-gw':
gw=sys.argv[i+1]
i=i+1
elifarg=='-h':
print"--stop-ue: Stop the UE. Turn on airplane mode"
print"--start-ue: Start the UE. Turn off airplane mode"
print"-gw: Specify the default gw as sometimes the gateway/route arguments are not set properly via wvdial"
else:
print" Script called with wrong arguments, arg = "+arg