Monkeyrunner throwing “ShellCommandUnrespo​nsiveException” - any work around?

旧时模样 提交于 2019-12-13 02:31:14

问题


I am facing some issues in device.shell('ping -c 2 192.168.1.1') inside a monkeyrunner script. Its throwing

ShellCommandUnrespo‌​nsiveException 
[main] [com.android.chimpchat.adb.AdbChimpDevice]com.android.ddmlib.ShellCommandUnrespo‌​nsiveException 
while (count<1000) :
device.shell('dmesg -c')
print '****swithing OFF wifi in loop NO-',count
device.touch(400,155,MonkeyDevice.DOWN_AND_UP)
time.sleep(10)
print '****switching ON wifi in loop NO-',count
device.touch(400,155,MonkeyDevice.DOWN_AND_UP)
time.sleep(25)
fd=open('pingstats.txt','a+b')
fd.write('***Loop-%i \n************\n%s\n****************\n' % (int(count),ping))
ping = device.shell('ping -c 2 192.168.1.1')
status=re.search('unreachable',ping)
if status:
    dmesg=device.shell('dmesg')
    fd.write(logcat)
fd.close()
count = count + 1

Please see above script. How can I fix this?


回答1:


your ping waits to long

add a -t

start with -t 1




回答2:


Just add -t . An example below works perfectly !

device.shell('pm enable packageName -t 15')


来源:https://stackoverflow.com/questions/9177645/monkeyrunner-throwing-shellcommandunresponsiveexception-any-work-around

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!