簡體   English   中英

AdbClient錯誤:[Errno 10053]建立的連接被中止

[英]AdbClient error: [Errno 10053] An established connection was aborted

發出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')

然后我沒有任何錯誤。 但是在一起,用同一代碼會產生上述錯誤。 發布多個設備命令時,我有什么不做的事情嗎?

我猜這有點棘手。 您的問題可能是由於device.takeSnapshot()被定義為

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

    ...

因此,如果您打算在使用快照后繼續使用連接

device.takeSnapshot(reconnect=True)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM