alibaba / web-editor

please use https://uiauto.dev instead
https://uiauto.dev
MIT License
1.24k stars 307 forks source link

OSError: cannot identify image file #68

Open mengdodo opened 4 years ago

mengdodo commented 4 years ago

环境:python3.6
网易mumu模拟器 1.8.5 通过浏览器访问 http://localhost:17310 点击connect后报错 ,搞不懂哪里出问题了,麻烦帮我看下,谢谢。

相关包

uiautomator2    2.4.2.dev1
weditor         0.4.2
Pillow          6.2.1

adb查看

(py36) 🌸 libingrong@超级本 ➜  快手极速版  adb devices
List of devices attached
emulator-5554   device

(py36) 🌸 libingrong@超级本 ➜  快手极速版  adb install com.kuaishou.nebula.apk
Performing Push Install
com.kuaishou.nebula.apk: 1 file pushed. 10.1 MB/s (86086663 bytes in 8.117s)
    pkg: /data/local/tmp/com.kuaishou.nebula.apk
Success

报错一

[I 191227 17:34:19 jsonrpc_client:57] READ: 'Successfully init AdbDevice(serial=emulator-5554)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: 'Traceback (most recent call last):\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/weditor/web/./jsonrpc_server.py", line 78, in run_device_code\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    ret = eval(code, _globals)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "<string>", line 1, in <module>\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/uiautomator2/session.py", line 536, in press\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    return self.jsonrpc.pressKey(key)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/uiautomator2/__init__.py", line 488, in __call__\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    params, http_timeout)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "</Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/decorator.py:decorator-gen-12>", line 2, in jsonrpc_retry_call\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/retry/api.py", line 74, in retry_decorator\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    logger)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/retry/api.py", line 33, in __retry_internal\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    return f()\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/uiautomator2/__init__.py", line 505, in jsonrpc_retry_call\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    return self.jsonrpc_call(*args, **kwargs)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/uiautomator2/__init__.py", line 561, in jsonrpc_call\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: '    "HTTP Return code is not 200", res.text)\n'
[I 191227 17:34:20 jsonrpc_client:57] READ: 'uiautomator2.exceptions.BaseError: (\'http://127.0.0.1:52980/jsonrpc/0\', b\'{"jsonrpc": "2.0", "id": "a525f54b5cd0fdcdb292d018a7b31625", "method": "pressKey", "params": ["home"]}\', 503, \'\', \'HTTP Return code is not 200\', \'\')\n'

报错二

[W 191227 17:34:23 api:40] cannot identify image file <_io.BytesIO object at 0x10c2f2048>, retrying in 0.5 seconds...
[W 191227 17:34:25 api:40] cannot identify image file <_io.BytesIO object at 0x10c2f2048>, retrying in 0.6 seconds...
[W 191227 17:34:27 api:40] cannot identify image file <_io.BytesIO object at 0x10c2f2048>, retrying in 0.7 seconds...
[W 191227 17:34:29 api:40] cannot identify image file <_io.BytesIO object at 0x10c2f2048>, retrying in 0.7999999999999999 seconds...
Traceback (most recent call last):
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/weditor/web/handlers/page.py", line 301, in get
    d.screenshot().convert("RGB").save(buffer, format='JPEG')
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/weditor/web/device.py", line 28, in screenshot
    return self._d.screenshot()
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/uiautomator2/__init__.py", line 1328, in screenshot
    return self.session().screenshot(*args, **kwargs)
  File "</Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/decorator.py:decorator-gen-6>", line 2, in screenshot
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/retry/api.py", line 74, in retry_decorator
    logger)
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/retry/api.py", line 33, in __retry_internal
    return f()
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/uiautomator2/session.py", line 487, in screenshot
    return Image.open(buff)
  File "/Users/libingrong/anaconda3/envs/py36/lib/python3.6/site-packages/PIL/Image.py", line 2818, in open
    raise IOError("cannot identify image file %r" % (filename if filename else fp))
OSError: cannot identify image file <_io.BytesIO object at 0x10c2f2048>

image