0

device.takeSnapshot() コマンドと device.touch() コマンドを発行すると、次のエラーが発生します。

    Traceback (most recent call last):
  File "C:\Users\Me\Desktop\AndroidViewClient_Bots\pytesser\insta_get_list_of
_users.py", line 82, in <module>
    device.touch(213,481, 'DOWN_AND_UP')
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 425, in touch
    self.shell('input tap %d %d' % (x, y))
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 257, in shell
    self.__send('shell:%s' % cmd, checkok=True, reconnect=False)
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 154, in __send
    self.__checkOk()
  File "C:\Python27\lib\site-packages\androidviewclient-7.0.2-py2.7.egg\com\dtmi
lano\android\adb\adbclient.py", line 184, in __checkOk
    recv = self.socket.recv(4)
socket.error: [Errno 10053] An established connection was aborted by the softwar
e in your host machine

これが私のコードです:

import sys
import os
import time
from PIL import Image # Python Image Library

try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.adb.adbclient import AdbClient, Device
from com.dtmilano.android.viewclient import ViewClient, View


device, serialno = ViewClient.connectToDeviceOrExit(verbose=True)


my_img = device.takeSnapshot()
device.touch(200,300, 'DOWN_AND_UP')

私が持っているだけなら本当に奇妙です

my_img = device.takeSnapshot() 

また

device.touch(200,300, 'DOWN_AND_UP')

その後、エラーは発生しません。しかし、同じコードで一緒にすると、上記のエラーが生成されます。複数のデバイス コマンドを発行するときに、私が行っていないことはありますか?

4

1 に答える 1

1

少しトリッキーだと思います。あなたの問題は、次のようにdevice.takeSnapshot()定義されているという事実から生じる可能性があります

def takeSnapshot(self, reconnect=False):
    '''
    Takes a snapshot of the device and return it as a PIL Image.
    '''

    ...

そのため、スナップショットを取得した後も接続を使用し続ける予定がある場合は、

device.takeSnapshot(reconnect=True)
于 2014-05-30T20:57:41.013 に答える