我有一个简单的代码片段,如下所示,使用AVC对Nexus3手机执行一些顺序操作。你知道吗
#! /usr/bin/python
import sys, os, time
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.adb.adbclient import AdbClient
#from com.dtmilano.android.viewclient import ViewClient
adbc=AdbClient(serialno='.*')
print 'taking snapshot...'
adbc.takeSnapshot()
print 'touch 1st time...'
adbc.touch(50,70)
time.sleep(1)
print 'touch 2nd time...'
adbc.touch(50,70)
对于touch()之前的takeSnapshot()代码,touch()失败,出现以下异常:
touch 1st time...
sending 0015shell:input tap 50 70
shell(cmd=input tap 50 70)
__send(shell:input tap 50 70, checkok=True, reconnect=False)
__checkOk()
checkConnected()
checkConnected: returning True
setAlarm(150)
__checkOk: recv= ''
setAlarm(0)
Traceback (most recent call last):
File "/home/swang/engine/test.py", line 19, in <module>
adbc.touch(50,70)
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 430, in touch
self.shell('input tap %d %d' % (x, y))
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 260, in shell
self.__send('shell:%s' % cmd, checkok=True, reconnect=False)
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 157, in __send
self.__checkOk()
File "/home/swang/engine/com/dtmilano/android/adb/adbclient.py", line 193, in __checkOk
raise RuntimeError("ERROR: %s %s" % (repr(recv), error))
RuntimeError: ERROR: ''
Closing socket... <socket._socketobject object at 0xa9da60>
但是如果我删除takeSnapshot(),下面的2 touch()将会成功。我用的是最近的AVC版本。我是不是忽略了什么?你知道吗
由于历史原因
AdbClient.takeSnapshot()
被定义为这意味着截图后会出现断开连接。 所以你在剧本里要做的就是
它会起作用的。你知道吗
相关问题 更多 >
编程相关推荐