refactor(fudai): 抽 run_once_basic 中"截图失败多次重试"日志块到 log_screenshot_failed
将 run_once_basic 中"获取截图失败(多次重试后仍失败)"的多字段日志块 (22 行)抽到 fudai_detail_helpers.log_screenshot_failed。 douyin_fudai.py: 3460 → 3447 行 (-13) fudai_detail_helpers.py: 83 → 120 行 验证: - pytest 1013 passed - compile OK Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
9675df2cdb
commit
77351bafd4
2 files changed
+45
-21
No files matched your search
@@ -1577,25 +1577,12 @@ class fudai_analyse:
|
||||
|
||||
screenshot_elapsed = time.time() - screenshot_start
|
||||
if not ok:
|
||||
elapsed = time.time() - start_time
|
||||
self._log_kv(
|
||||
"截图",
|
||||
"获取截图失败(多次重试后仍失败)",
|
||||
ok=0,
|
||||
retries=max_screenshot_retries,
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
screenshot_elapsed_seconds=round(screenshot_elapsed, 2),
|
||||
reservation_after_action_pending=bool(
|
||||
getattr(self, "reservation_after_action_pending", False)
|
||||
),
|
||||
reservation_focus_until_ts=float(
|
||||
getattr(self, "reservation_focus_until_ts", 0.0) or 0.0
|
||||
),
|
||||
waiting_for_lottery=bool(
|
||||
getattr(self, "_waiting_for_lottery_result", False)
|
||||
),
|
||||
room_pos=int(getattr(self, "room_pos", 0) or 0),
|
||||
suggestion="检查设备连接状态和ADB服务",
|
||||
from douyin.core.fudai_modules.fudai_detail_helpers import (
|
||||
log_screenshot_failed,
|
||||
)
|
||||
|
||||
log_screenshot_failed(
|
||||
self, start_time, screenshot_elapsed, max_screenshot_retries
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
@@ -1,9 +1,46 @@
|
||||
"""_handle_in_fudai_detail 辅助函数
|
||||
"""_handle_in_fudai_detail / run_once_basic 辅助函数
|
||||
|
||||
从 douyin_fudai.py:_handle_in_fudai_detail 中提取的相对独立的早返回块。
|
||||
从 douyin_fudai.py 中提取的相对独立的早返回块。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
|
||||
def log_screenshot_failed(
|
||||
analyser,
|
||||
start_time: float,
|
||||
screenshot_elapsed: float,
|
||||
max_retries: int,
|
||||
) -> None:
|
||||
"""run_once_basic 步骤1:多次重试后截图仍失败时的日志记录。
|
||||
|
||||
调用方应在调用后立即 return。
|
||||
"""
|
||||
try:
|
||||
elapsed = time.time() - start_time
|
||||
analyser._log_kv(
|
||||
"截图",
|
||||
"获取截图失败(多次重试后仍失败)",
|
||||
ok=0,
|
||||
retries=max_retries,
|
||||
elapsed_seconds=round(elapsed, 2),
|
||||
screenshot_elapsed_seconds=round(screenshot_elapsed, 2),
|
||||
reservation_after_action_pending=bool(
|
||||
getattr(analyser, "reservation_after_action_pending", False)
|
||||
),
|
||||
reservation_focus_until_ts=float(
|
||||
getattr(analyser, "reservation_focus_until_ts", 0.0) or 0.0
|
||||
),
|
||||
waiting_for_lottery=bool(
|
||||
getattr(analyser, "_waiting_for_lottery_result", False)
|
||||
),
|
||||
room_pos=int(getattr(analyser, "room_pos", 0) or 0),
|
||||
suggestion="检查设备连接状态和ADB服务",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def clear_task_count_flag(analyser) -> None:
|
||||
"""清除任务数量标志(_fudai_detail_task_count_from_stage = None)。
|
||||
|
||||
Reference in new issue
Block a user