Skip to content

Commit d3dccb7

Browse files
committed
update comments
(cherry picked from commit 34b5b2e)
1 parent accab6f commit d3dccb7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

airtest/core/android/adb.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def push(self, local, remote):
461461
if os.path.isfile(local) and os.path.splitext(local)[-1] != os.path.splitext(remote)[-1]:
462462
# If remote is a folder, add the filename and escape
463463
filename = os.path.basename(local)
464-
# 把文件名中的空格、括号等符号,添加转义符,以便adb push后的文件名正确
464+
# Add escape characters for spaces, parentheses, etc. in filenames
465465
filename = re.sub(r"[ \(\)\&]", lambda m: "\\" + m.group(0), filename)
466466
remote = '%s/%s' % (remote, filename)
467467
self.cmd(["push", local, remote], ensure_unicode=False)
@@ -677,8 +677,6 @@ def pm_install(self, filepath, replace=False, install_options=None):
677677
678678
Note:
679679
This is more reliable and recommended way of installing `.apk` files
680-
Do not use filenames with spaces
681-
请勿使用带空格的文件名!
682680
683681
Args:
684682
filepath: full path to file to be installed on the device

airtest/core/android/cap_methods/javacap.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def get_frames(self):
7070
try:
7171
t = s.recv(24)
7272
except Exception as e:
73-
# 在部分手机上,可能连接可以成功建立,但是在开始获取数据时会报错
73+
# On some phones, the connection can be established successfully,
74+
# but an error is reported when starting to fetch data
7475
raise ScreenError(e)
7576
# javacap header
7677
LOGGING.debug(struct.unpack("<2B5I2B", t))
@@ -117,7 +118,6 @@ def _cleanup(self):
117118
"""
118119
Cleanup javacap process and stream reader
119120
120-
和minicap类似
121121
Returns:
122122
123123
"""

airtest/core/android/cap_methods/minicap.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, adb, projection=None, rotation_watcher=None, display_id=None,
6060
# minicap需要在横竖屏转换时,重新连接
6161
rotation_watcher.reg_callback(lambda x: self.update_rotation(x * 90))
6262
self.cleanup_func = []
63-
# 默认的清理操作,在退出时断开连接
63+
# Force cleanup on exit
6464
reg_cleanup(self.teardown_stream)
6565

6666
@ready_method
@@ -262,8 +262,9 @@ def _get_stream(self, lazy=True):
262262
s.send(b"1")
263263
# recv frame header, count frame_size
264264
if self.RECVTIMEOUT is not None:
265-
# 部分手机在横竖屏切换时,可能会卡在这里一直等待recv数据,导致旧的minicap进程未完全结束
266-
# 这可能会使新的minicap拿到的画面只有一半,另外一半黑屏,因此1.2.7以上版本强制设置超时时间为3s
265+
# Some mobile phones may keep waiting for data when switching between horizontal and vertical screens,
266+
# and the connection is not closed, resulting in a black screen
267+
# Set the timeout to 3s(airtest>=1.2.7)
267268
header = s.recv_with_timeout(4, self.RECVTIMEOUT)
268269
else:
269270
header = s.recv(4)
@@ -280,8 +281,8 @@ def _get_stream(self, lazy=True):
280281
stopping = yield frame_data
281282

282283
LOGGING.debug("minicap stream ends")
283-
# 这里只调用_cleanup(),清理掉本次连接创建的进程即可
284-
# 不直接调用teardown_stream(),因为在屏幕旋转时可能会多次重建连接,self.frame_gen可能会卡住
284+
# teardown stream() cannot be called directly because the connection may be rebuilt multiple times
285+
# while the screen is rotated, and self.frame_gen gets stuck
285286
self._cleanup()
286287

287288
def _setup_stream_server(self, lazy=False):
@@ -387,6 +388,7 @@ def _cleanup(self):
387388
388389
主动将minicap建立的各个连接关闭
389390
与snippet.py中的CLEANUP_CALLS功能相同,但是允许主动调用,避免异常退出时有遗漏进程没清理干净
391+
390392
Returns:
391393
392394
"""
@@ -402,7 +404,7 @@ def teardown_stream(self):
402404
None
403405
404406
"""
405-
# 主动清理一次之前建立的连接
407+
# clean up established connections
406408
self._cleanup()
407409
if not self.frame_gen:
408410
return

airtest/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from airtest.core.helper import (G, delay_after_operation, import_device_cls,
1515
logwrap, set_logdir, using, log)
1616
# Assertions
17-
from airtest.core.assertions import (assert_exists, assert_not_exists, assert_equal, assert_not_equal,
17+
from airtest.core.assertions import (assert_exists, assert_not_exists, assert_equal, assert_not_equal, # noqa
1818
assert_true, assert_false, assert_is, assert_is_not,
1919
assert_is_none, assert_is_not_none, assert_in, assert_not_in,
2020
assert_is_instance, assert_not_is_instance

0 commit comments

Comments
 (0)