'commit'
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# coding=utf-8
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
import asyncio
|
||||
import hashlib
|
||||
|
||||
@@ -185,6 +185,9 @@ def clear_directory(dir_path, exclude_files=None):
|
||||
os.unlink(file_path)
|
||||
elif os.path.isdir(file_path):
|
||||
shutil.rmtree(file_path)
|
||||
except PermissionError:
|
||||
# 忽略正在被使用的文件(如当前的日志文件)
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to delete {file_path}. Reason: {e}")
|
||||
|
||||
@@ -226,14 +229,17 @@ def safe_device_click(d, x, y):
|
||||
安全的点击操作,包含简单的异常捕获和重试逻辑
|
||||
"""
|
||||
try:
|
||||
d.click(x, y)
|
||||
# 强制转换为原生 int,防止 numpy.int64 导致的 JSON 序列化错误
|
||||
ix, iy = int(x), int(y)
|
||||
d.click(ix, iy)
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.warning(f"点击操作失败 ({x}, {y}): {e},尝试重新连接并重试...")
|
||||
try:
|
||||
# 尝试重新初始化连接
|
||||
new_d = u2.connect()
|
||||
new_d.click(x, y)
|
||||
ix, iy = int(x), int(y)
|
||||
new_d.click(ix, iy)
|
||||
return True
|
||||
except Exception as e2:
|
||||
logger.error(f"重试点击操作依然失败: {e2}")
|
||||
@@ -818,7 +824,7 @@ async def analyze_chat_image(image_path, output_path, device=None, target_name="
|
||||
|
||||
# 执行操作:长按 -> 转文字
|
||||
logger.info(f"正在长按语音消息 ({vx}, {vy})...")
|
||||
d.long_click(vx, vy, 1.0) # 缩短按压时间
|
||||
d.long_click(int(vx), int(vy), 1.0) # 确保坐标为原生 int
|
||||
|
||||
# 轮询寻找“转文字”按钮
|
||||
logger.info("正在快速寻找'转文字'按钮...")
|
||||
@@ -895,7 +901,7 @@ async def analyze_chat_image(image_path, output_path, device=None, target_name="
|
||||
if restore_processed_voice:
|
||||
logger.info("准备还原状态 (取消转文字)...")
|
||||
|
||||
d.long_click(vx, vy, 1.0) # 盲点原坐标
|
||||
d.long_click(int(vx), int(vy), 1.0) # 确保坐标为原生 int
|
||||
|
||||
logger.info("正在快速寻找'隐藏文字'按钮...")
|
||||
cancel_template = os.path.join(TEMPLATE_DIR, "cancel_zhuan_wen_zi.jpg")
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user