NetEaseGame / ATX

Smart phone automation tool. Support iOS, Android, WebApp and game.
Apache License 2.0
1.58k stars 422 forks source link

Python3.5环境下Weditor的两个问题 #119

Closed mexth closed 7 years ago

mexth commented 7 years ago

更新到最新版本后,在python3的环境下使用weditor发现两个问题: 问题1: 使用weditor执行tap操作时候可以正常生成命令,手机端也执行了点击操作,但是web端视图更新不成功,一直在转圈。查看cmd端发现有出错的log

listen port 17310
WARNING:tornado.access:404 GET /api/v1/contents/main.py (::1) 1.00ms
INFO:tornado.access:304 GET /api/v1/version (::1) 1.00ms
SN default
INFO:tornado.access:200 GET /api/v1/devices/default/screenshot (::1) 1491.60ms
INFO:tornado.access:200 GET /api/v1/devices/default/uiview (::1) 230.97ms
INFO:tornado.access:101 GET /ws/v1/build (::1) 1.00ms
Websocket opened
DEBUG: run code b'# coding: utf-8\nimport atx\nd = atx.connect()\nd(description="\xe6\x9b\xb4\xe5\xa4\x9a\xe9\x80\x89\xe9\xa1\xb9").click()'
recv subprocess: b"('jsonrpc method:', 'click')\r\n"
Traceback (most recent call last):
  File "C:\Python3\lib\site-packages\weditor\__main__.py", line 298, in _run
    self.write_message({"buffer": line})
  File "C:\Python3\lib\site-packages\tornado\websocket.py", line 251, in write_message
    message = tornado.escape.json_encode(message)
  File "C:\Python3\lib\site-packages\tornado\escape.py", line 82, in json_encode
    return json.dumps(value).replace("</", "<\\/")
  File "C:\Python3\lib\json\__init__.py", line 230, in dumps
    return _default_encoder.encode(obj)
  File "C:\Python3\lib\json\encoder.py", line 198, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Python3\lib\json\encoder.py", line 256, in iterencode
    return _iterencode(o, 0)
  File "C:\Python3\lib\json\encoder.py", line 179, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b"('jsonrpc method:', 'click')\r\n" is not JSON serializable

问题2: 多设备连着的时候,使用weditor,输入serialno来链接,可以成功,但是执行点击操作生成脚本的过程中,手机端listen port 17310

WARNING:tornado.access:404 GET /api/v1/contents/main.py (::1) 1.00ms
INFO:tornado.access:304 GET /api/v1/version (::1) 0.99ms
SN CB5A21SX9A
INFO:tornado.access:200 GET /api/v1/devices/CB5A21SX9A/screenshot (::1) 1475.97ms
INFO:tornado.access:200 GET /api/v1/devices/CB5A21SX9A/uiview (::1) 193.67ms
INFO:tornado.access:101 GET /ws/v1/build (::1) 1.00ms
Websocket opened
DEBUG: run code b'# coding: utf-8\nimport atx\nd = atx.connect()\nd(description="\xe6\x9b\xb4\xe5\xa4\x9a\xe9\x80\x89\xe9\xa1\xb9").click()'
Traceback (most recent call last):
  File "C:\Python3\lib\site-packages\weditor\__main__.py", line 291, in _run
    env=env, stdout=PIPE, stderr=subprocess.STDOUT, stdin=PIPE, bufsize=1)
  File "C:\Python3\lib\subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "C:\Python3\lib\subprocess.py", line 955, in _execute_child
    startupinfo)
TypeError: environment can only contain strings不会同步执行相关操作。
codeskyblue commented 7 years ago

提供下weditor的版本 pip show weditor

mexth commented 7 years ago

0.0.3.dev10

codeskyblue commented 7 years ago

我不确定是不是修好了,你更新到0.0.3.dev11试试

mexth commented 7 years ago

单设备python3环境下使用正常啦,多设备选择其中之一进行连接操作还是有问题。 log如下:

listen port 17310
WARNING:tornado.access:404 GET /api/v1/contents/main.py (::1) 1.50ms
INFO:tornado.access:304 GET /api/v1/version (::1) 1.00ms
SN CB5A21SX9A
INFO:tornado.access:200 GET /api/v1/devices/CB5A21SX9A/screenshot (::1) 1878.30ms
INFO:tornado.access:200 GET /api/v1/devices/CB5A21SX9A/uiview (::1) 250.19ms
INFO:tornado.access:101 GET /ws/v1/build (::1) 0.50ms
Websocket opened
DEBUG: run code b'# coding: utf-8\nimport atx\nd = atx.connect()\nd(className="android.widget.RelativeLayout", instance=3).click()'
Traceback (most recent call last):
  File "C:\Python3\lib\site-packages\weditor\__main__.py", line 291, in _run
    env=env, stdout=PIPE, stderr=subprocess.STDOUT, stdin=PIPE, bufsize=1)
  File "C:\Python3\lib\subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "C:\Python3\lib\subprocess.py", line 955, in _execute_child
    startupinfo)
TypeError: environment can only contain strings
codeskyblue commented 7 years ago

用这个版本尝试下试试 0.0.3.dev14

mexth commented 7 years ago

0.0.3.dev14 已经解决了问题,切换任意一台都可以正常生成命令,同步显示截图。