feat: Enhance logging and parameter tracking capabilities

- Refactor `gui_core.py` to improve code readability and maintainability by adding line breaks for long statements.
- Introduce `inspect_lines.py` script for inspecting specific line ranges in files.
- Add `generate_param_locations.py` to scan the repository and generate a report of function definitions, argparse parameters, and tracking calls.
- Implement `param_usage_tool.py` for analyzing `param_usage.json` records and scanning code for tracking calls.
- Create `simulate_reservation_preempted_flow.py` and `simulate_reservation_preempted_flow_dynamic.py` to validate behavior of reservation logic under specific conditions.
- Add global parameter tracking feature in `run_cli.py` to enable detailed usage tracing.
This commit is contained in:
Your Name committed 2026-01-03 19:12:58 +08:00
1 parent 68c8ccea66
commit 95b4517bdd
23 files changed
+1560 -849

No files matched your search

+117 -31
View File
@@ -262,9 +262,7 @@ def main():
# 创建日志写入器实例
log_writer = ThreadSafeLogWriter()
"""
日志格式化已移至模块级别函数 format_gui_log_line()
"""
# 日志格式化已移至模块级别函数 format_gui_log_line()
def on_line(line: str):
"""处理日志行:GUI 显示用精简版本,文件写入用完整版本"""
@@ -2057,8 +2055,7 @@ def main():
def screenshot_thread():
try:
from Underlying_Operations import underlying_operations
from PIL import Image
import os
# 使用模块级别导入的 Image 与 os,避免重复导入导致 Pylance 警告
# 使用 root.after 在主线程中更新日志
def log_msg(msg: str) -> Callable[[], None]:
@@ -2214,6 +2211,7 @@ def main():
reservation_tab = ttk.Frame(notebook)
high_value_tab = ttk.Frame(notebook)
actions_log_tab = ttk.Frame(notebook)
realtime_tab = ttk.Frame(notebook)
ocr_results_tab = ttk.Frame(notebook)
win_record_tab = ttk.Frame(notebook)
notebook.add(log_tab, text="运行日志")
@@ -2222,6 +2220,7 @@ def main():
notebook.add(reservation_tab, text="预约队列")
notebook.add(high_value_tab, text="高价值房间")
notebook.add(actions_log_tab, text="行为日志")
notebook.add(realtime_tab, text="实时状态")
notebook.add(ocr_results_tab, text="OCR结果")
notebook.add(win_record_tab, text="中奖记录")
@@ -2229,6 +2228,109 @@ def main():
log_box = ttk.Frame(log_tab)
log_box.pack(fill=BOTH, expand=True)
# ========== 实时状态 Tab(显示最近动作 + 耗时) ==========
try:
realtime_frame = ttk.Frame(realtime_tab)
realtime_frame.pack(fill=BOTH, expand=True, padx=8, pady=8)
realtime_text = ScrolledText(realtime_frame, height=20)
realtime_text.pack(fill=BOTH, expand=True)
realtime_text.configure(state="disabled")
# re 已在模块顶部导入,避免重复导入
realtime_after_id = None
def tail_read_file(path: str, max_bytes: int = 64 * 1024) -> list[str]:
"""从文件尾部读取最多 max_bytes,并返回按行分割的字符串列表(按文件顺序)。"""
try:
if not os.path.exists(path):
return []
with open(path, "rb") as f:
f.seek(0, os.SEEK_END)
file_size = f.tell()
seek_from = max(0, file_size - max_bytes)
f.seek(seek_from)
data = f.read()
text = data.decode(errors="ignore")
# splitlines 保留不含尾部换行的处理
return text.splitlines()
except Exception:
return []
def parse_action_duration(line: str) -> tuple[str, str] | None:
"""从一行日志提取 (action, duration),未找到返回 None。"""
if "耗时" not in line:
return None
# 尝试提取耗时数字
m = re.search(r"耗时[:=]?\s*([0-9]+(?:\.[0-9]+)?)\s*s", line)
dur = None
if m:
dur = m.group(1) + "s"
else:
m2 = re.search(r"([0-9]+(?:\.[0-9]+)?)\s*s", line)
if m2:
dur = m2.group(1) + "s"
if not dur:
return None
# 动作名取耗时之前的文本片段,最多保留 60 字符
idx = line.find("耗时")
action = line[:idx].strip()
if not action:
# 兜底:取整行前 60 字符
action = line.strip()[:60]
if len(action) > 60:
action = action[:57] + "..."
return (action, dur)
def refresh_realtime_tab():
nonlocal realtime_after_id
cfg = read_config()
gui_cfg = cfg.get("gui", {}).get("realtime_status", {})
refresh_ms = int(gui_cfg.get("refresh_interval_ms", 1000))
tail_items = int(gui_cfg.get("tail_items", 50))
path = os.path.join(get_logs_dir(), "actions.log")
lines = tail_read_file(path)
parsed: list[tuple[str, str]] = []
# 从文件末尾向前解析,保持原始顺序输出最近项
for line in reversed(lines):
try:
out = parse_action_duration(line)
if out:
parsed.append(out)
if len(parsed) >= tail_items:
break
except Exception:
continue
parsed = list(reversed(parsed))
realtime_text.configure(state="normal")
realtime_text.delete("1.0", "end")
if not parsed:
realtime_text.insert("1.0", "暂无动作日志(仅显示包含“耗时”的行)")
else:
for action, dur in parsed:
realtime_text.insert("end", f"{action} {dur}\n")
realtime_text.configure(state="disabled")
# 安排下一次刷新
try:
realtime_after_id = root.after(refresh_ms, refresh_realtime_tab)
except Exception:
realtime_after_id = None
# 启动刷新(仅在 Tab 被创建时启动)
try:
refresh_realtime_tab()
except Exception:
pass
except Exception:
pass
# 搜索工具栏
log_search_frame = ttk.Frame(log_box)
log_search_frame.pack(fill=X, padx=10, pady=(10, 5))
@@ -2811,12 +2913,10 @@ def main():
last_log_ts = stats.get("last_log_ts")
if last_log_ts:
import datetime
dt = datetime.datetime.fromtimestamp(last_log_ts)
lines.append(f"最近日志时间: {dt.strftime('%Y-%m-%d %H:%M:%S')}")
dt = datetime.fromtimestamp(last_log_ts)
lines.append("最近日志时间: " + dt.strftime("%Y-%m-%d %H:%M:%S"))
else:
lines.append(f"最近日志时间: -")
lines.append("最近日志时间: -")
exit_code = stats.get("exit_code")
lines.append(f"退出码: {exit_code if exit_code is not None else '-'}")
@@ -3433,10 +3533,8 @@ def main():
lines.append(f"奖品价值: {prize_value} 元")
updated_ts = fudai_last.get("updated_ts")
if updated_ts:
import datetime
dt = datetime.datetime.fromtimestamp(updated_ts)
lines.append(f"更新时间: {dt.strftime('%Y-%m-%d %H:%M:%S')}")
dt = datetime.fromtimestamp(updated_ts)
lines.append("更新时间: " + dt.strftime("%Y-%m-%d %H:%M:%S"))
lines.append("")
# 中奖记录
@@ -3446,13 +3544,9 @@ def main():
lines.append(f"最近中奖记录(显示最近 {len(wins)} 条)")
lines.append("=" * 60)
for i, win in enumerate(wins[-10:], 1): # 只显示最近10条
import datetime
ts = win.get("ts", 0)
dt_str = (
datetime.datetime.fromtimestamp(ts).strftime(
"%Y-%m-%d %H:%M:%S"
)
datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M:%S")
if ts
else "-"
)
@@ -3514,8 +3608,6 @@ def main():
data = json.load(f)
reservation_text.delete("1.0", "end")
from datetime import datetime
updated_ts = (
float(data.get("updated_ts", 0.0) or 0.0)
if isinstance(data, dict)
@@ -3710,13 +3802,13 @@ def main():
# 格式化显示
lines.append(
f"┌─ 预约 #{idx} ─────────────────────────────────────────────"
"┌─ 预约 #" + str(idx) + " ─────────────────────────────────────────────"
)
lines.append(f"│ 状态:{status_icon} {remain_str}")
lines.append(f"│")
lines.append("│")
lines.append(f"│ 💰 奖品价值:{val:.2f} 元")
lines.append(f"│ 📦 奖品内容:{content or '(无描述)'}")
lines.append(f"│")
lines.append("│")
lines.append(f"│ ⏰ 预计开奖时间:{ft_str or '未知'}")
if ft > 0:
try:
@@ -3728,7 +3820,7 @@ def main():
lines.append(f"│ 详细时间:{ft_str_detailed}")
except Exception:
pass
lines.append(f"│")
lines.append("│")
lines.append(
f"│ 📍 发现时直播间位置:第 {pos_seen + 1} 个直播间(索引:{pos_seen})"
)
@@ -4213,8 +4305,6 @@ def main():
for idx, (file, file_path, mtime) in enumerate(win_images):
# 格式化显示:文件名 + 时间
try:
from datetime import datetime
dt = datetime.fromtimestamp(mtime)
time_str = dt.strftime("%Y-%m-%d %H:%M:%S")
display_text = f"{file} ({time_str})"
@@ -4338,8 +4428,6 @@ def main():
return
try:
import json
with open(false_positive_file, "r", encoding="utf-8") as f:
data = json.load(f)
false_positives = data.get("false_positives", [])
@@ -4372,8 +4460,6 @@ def main():
lines = [line.strip() for line in content.splitlines() if line.strip()]
try:
import json
with open(false_positive_file, "w", encoding="utf-8") as f:
json.dump({"false_positives": lines}, f, ensure_ascii=False, indent=2)
on_line(f"[中奖记录] 已保存 {len(lines)} 条误识别记录")
+109 -36
View File
@@ -30,7 +30,9 @@ def find_adb_executable() -> str:
# 兼容某些人手动放到用户目录的情况
userprofile = os.environ.get("USERPROFILE") or ""
if userprofile:
candidates.append(os.path.join(userprofile, "AppData", "Local", "platform-tools", "adb.exe"))
candidates.append(
os.path.join(userprofile, "AppData", "Local", "platform-tools", "adb.exe")
)
for p in candidates:
if os.path.exists(p):
@@ -137,7 +139,7 @@ class Runner:
with self._lock:
self._events.append(ev)
if len(self._events) > self._events_cap:
self._events = self._events[-self._events_cap:]
self._events = self._events[-self._events_cap :]
def _record_win(self) -> None:
item = {
@@ -147,7 +149,7 @@ class Runner:
with self._lock:
self._wins.append(item)
if len(self._wins) > self._wins_cap:
self._wins = self._wins[-self._wins_cap:]
self._wins = self._wins[-self._wins_cap :]
def _snapshot_fudai(self) -> dict:
with self._lock:
@@ -172,7 +174,9 @@ class Runner:
content_extracted = False
if "福袋内容:" in s:
with self._lock:
self._fudai_last["content"] = s.split("福袋内容:", 1)[1].strip().split()[0] # 只取第一个词,避免包含后续字段
self._fudai_last["content"] = (
s.split("福袋内容:", 1)[1].strip().split()[0]
) # 只取第一个词,避免包含后续字段
self._fudai_last["updated_ts"] = time.time()
content_extracted = True
else:
@@ -209,7 +213,9 @@ class Runner:
# 倒计时:支持多种格式
if "倒计时时间:" in s:
with self._lock:
self._fudai_last["countdown"] = s.split("倒计时时间:", 1)[1].strip().split()[0]
self._fudai_last["countdown"] = (
s.split("倒计时时间:", 1)[1].strip().split()[0]
)
self._fudai_last["updated_ts"] = time.time()
else:
m = re.search(r"(?:字段_)?倒计时[=:]?\s*([^\s]+)", s)
@@ -219,7 +225,9 @@ class Runner:
self._fudai_last["updated_ts"] = time.time()
# 奖品价值:支持多种格式
m = re.search(r"(?:字段_)?(?:价值|价值元|奖品价值)[=:]?\s*([0-9]+(?:\.[0-9]+)?)", s)
m = re.search(
r"(?:字段_)?(?:价值|价值元|奖品价值)[=:]?\s*([0-9]+(?:\.[0-9]+)?)", s
)
if not m:
m = re.search(r"奖品价值:\s*([0-9]+(?:\.[0-9]+)?)\s*元", s)
if m:
@@ -234,7 +242,9 @@ class Runner:
if "点击打开福袋详情" in s or ("[流程]" in s and "检测到福袋图标并点击" in s):
self._inc("fudai_open_detail")
self._record_event("fudai_open_detail", self._snapshot_fudai())
if "点击参与抽奖" in s or ("[参与]" in s and ("动作=点击参与" in s or "动作=参与" in s)):
if "点击参与抽奖" in s or (
"[参与]" in s and ("动作=点击参与" in s or "动作=参与" in s)
):
self._inc("fudai_click_attend")
self._record_event("fudai_click_attend", self._snapshot_fudai())
@@ -243,7 +253,10 @@ class Runner:
"已经参与,等待开奖" in s
or "已经参与,等待看播时间凑齐开奖" in s
or "已参与成功(或看播中)" in s
or ("[参与]" in s and ("结果=已参与" in s or "结果=看播中" in s or "结果=参与成功" in s))
or (
"[参与]" in s
and ("结果=已参与" in s or "结果=看播中" in s or "结果=参与成功" in s)
)
or ("[参与]" in s and "已参与" in s and "等待开奖" in s)
or ("预约回退后直接参与" in s and "参与成功" in s)
):
@@ -307,7 +320,9 @@ class Runner:
self._record_event("fudai_skip", {"reason": "value_low", **meta})
if "福袋内容不理想" in s or ("[筛选]" in s and "内容" in s and "黑名单" in s):
self._inc("fudai_skip_content")
self._record_event("fudai_skip", {"reason": "content", **self._snapshot_fudai()})
self._record_event(
"fudai_skip", {"reason": "content", **self._snapshot_fudai()}
)
if "抽奖倒计时时间小于" in s and "不参与" in s:
self._inc("fudai_skip_countdown_short")
# 提取倒计时秒数
@@ -336,7 +351,9 @@ class Runner:
or ("[参与]" in s and "结果=看播门槛" in s)
):
self._inc("fudai_skip_watch_required")
self._record_event("fudai_skip", {"reason": "watch_required", **self._snapshot_fudai()})
self._record_event(
"fudai_skip", {"reason": "watch_required", **self._snapshot_fudai()}
)
if "打开福袋异常" in s or ("[流程]" in s and "打开福袋异常" in s):
self._inc("fudai_open_error")
self._record_event("fudai_open_error", self._snapshot_fudai())
@@ -344,7 +361,9 @@ class Runner:
self._inc("fudai_open_error_too_many")
self._record_event("fudai_open_error_too_many", self._snapshot_fudai())
# 倒计时大于阈值但价值达到高价值阈值,记录预约
if ("[流程]" in s and "倒计时大于阈值,但价值达到高价值阈值,记录预约" in s) or ("[参与]" in s and "倒计时大于阈值,但价值达到高价值阈值,记录预约" in s):
if (
"[流程]" in s and "倒计时大于阈值,但价值达到高价值阈值,记录预约" in s
) or ("[参与]" in s and "倒计时大于阈值,但价值达到高价值阈值,记录预约" in s):
self._inc("fudai_reserved_high_value")
# 提取价值和倒计时信息
meta = self._snapshot_fudai()
@@ -415,7 +434,9 @@ class Runner:
self._record_event("error_config_load", {})
# --- 状态文件错误 ---
if ("预约队列状态文件" in s or "reservations.json" in s) and ("失败" in s or "错误" in s):
if ("预约队列状态文件" in s or "reservations.json" in s) and (
"失败" in s or "错误" in s
):
self._inc("error_state_file")
self._record_event("error_state_file", {})
@@ -441,13 +462,17 @@ class Runner:
self._record_event("fansclub_unresolved", self._snapshot_fudai())
# --- 预约队列/回退校验 ---
if ("[预约]" in s and "回退校验通过" in s) or "回退校验通过:已回到目标直播间" in s:
if (
"[预约]" in s and "回退校验通过" in s
) or "回退校验通过:已回到目标直播间" in s:
self._inc("reservation_back_verify_ok")
self._record_event("reservation_back_verify_ok", {})
if ("[预约]" in s and "回退校验失败" in s) or "回退校验失败" in s:
self._inc("reservation_back_verify_fail")
self._record_event("reservation_back_verify_fail", {})
if ("[预约]" in s and "预约队列已满,丢弃最低价值" in s) or "预约队列已满,丢弃最低价值" in s:
if (
"[预约]" in s and "预约队列已满,丢弃最低价值" in s
) or "预约队列已满,丢弃最低价值" in s:
self._inc("reservation_drop_low_value")
self._record_event("reservation_drop_low_value", {})
if ("[预约]" in s and "清空预约队列" in s) or "清空预约队列" in s:
@@ -455,7 +480,9 @@ class Runner:
self._record_event("reservation_clear", {})
# --- 预约记录相关 ---
if ("[预约]" in s and "已记录高价值福袋" in s) or "record_high_value_reservation:已记录高价值福袋" in s:
if (
"[预约]" in s and "已记录高价值福袋" in s
) or "record_high_value_reservation:已记录高价值福袋" in s:
self._inc("reservation_recorded")
# 提取预约价值:支持多种格式
value = None
@@ -477,7 +504,9 @@ class Runner:
pass
# 提取直播间名称
room_title = None
m = re.search(r"(?:字段_)?(?:直播间|直播间名|room_title)[=:]?\s*([^\s]+)", s)
m = re.search(
r"(?:字段_)?(?:直播间|直播间名|room_title)[=:]?\s*([^\s]+)", s
)
if m:
room_title = m.group(1).strip()
meta = self._snapshot_fudai()
@@ -488,10 +517,16 @@ class Runner:
if room_title:
meta["room_title"] = room_title
self._record_event("reservation_recorded", meta)
if ("[预约]" in s and "进入预约参与窗口" in s) or "进入预约参与窗口,准备回退到目标直播间" in s:
if (
"[预约]" in s and "进入预约参与窗口" in s
) or "进入预约参与窗口,准备回退到目标直播间" in s:
self._inc("reservation_window_entered")
self._record_event("reservation_window_entered", {})
if ("[预约]" in s and "已回退到目标直播间" in s) or "已回退到目标直播间" in s or ("[预约]" in s and "已回退到最早开奖的预约直播间" in s):
if (
("[预约]" in s and "已回退到目标直播间" in s)
or "已回退到目标直播间" in s
or ("[预约]" in s and "已回退到最早开奖的预约直播间" in s)
):
self._inc("reservation_back_success")
# 提取回退信息
meta = {}
@@ -505,21 +540,29 @@ class Runner:
if ("[预约]" in s and "时间窗口未到" in s) or "时间窗口未到,跳过回退" in s:
self._inc("reservation_window_not_reached")
self._record_event("reservation_window_not_reached", {})
if ("[预约]" in s and "已明显错过开奖时间" in s) or "已明显错过开奖时间,清理过期预约" in s:
if (
"[预约]" in s and "已明显错过开奖时间" in s
) or "已明显错过开奖时间,清理过期预约" in s:
self._inc("reservation_expired")
self._record_event("reservation_expired", {})
if ("[预约]" in s and "预约队列为空" in s) or "process_reservation_attend_window:预约队列为空" in s:
if (
"[预约]" in s and "预约队列为空" in s
) or "process_reservation_attend_window:预约队列为空" in s:
self._inc("reservation_queue_empty")
if ("[预约]" in s and "锁定期未结束" in s) or "锁定期未结束" in s:
self._inc("reservation_locked")
self._record_event("reservation_locked", {})
if ("[预约]" in s and "已回退到第一个直播间" in s):
if "[预约]" in s and "已回退到第一个直播间" in s:
self._inc("reservation_back_to_first")
self._record_event("reservation_back_to_first", {})
if ("[预约]" in s and "run_once_basic:检查预约回退触发条件" in s):
if "[预约]" in s and "run_once_basic:检查预约回退触发条件" in s:
self._inc("reservation_check_triggered")
# 预约队列满时等待
if ("[预约]" in s and "队列已满" in s) or "handle_queue_full_wait_at_earliest" in s or ("[预约]" in s and "队列已满,回退到最早开奖的预约直播间" in s):
if (
("[预约]" in s and "队列已满" in s)
or "handle_queue_full_wait_at_earliest" in s
or ("[预约]" in s and "队列已满,回退到最早开奖的预约直播间" in s)
):
self._inc("reservation_queue_full_wait")
self._record_event("reservation_queue_full_wait", {})
# 回退后直接参与
@@ -527,11 +570,11 @@ class Runner:
self._inc("reservation_back_direct_attend")
self._record_event("reservation_back_direct_attend", {})
# 队列满回退后设置参与标志
if ("[预约]" in s and "队列满回退后,直接设置参与标志" in s):
if "[预约]" in s and "队列满回退后,直接设置参与标志" in s:
self._inc("reservation_queue_full_back_attend")
self._record_event("reservation_queue_full_back_attend", {})
# 通过相似度匹配识别重复预约
if ("[预约]" in s and "通过相似度匹配识别为重复预约" in s):
if "[预约]" in s and "通过相似度匹配识别为重复预约" in s:
self._inc("reservation_duplicate_detected")
self._record_event("reservation_duplicate_detected", {})
@@ -539,7 +582,11 @@ class Runner:
if "没有抽中" in s and "关闭弹窗" in s:
self._inc("fudai_result_no_win")
self._record_event("fudai_result_no_win", self._snapshot_fudai())
if "恭喜中奖了" in s or "检测到中奖结果" in s or ("[开奖结果]" in s and "中奖" in s):
if (
"恭喜中奖了" in s
or "检测到中奖结果" in s
or ("[开奖结果]" in s and "中奖" in s)
):
self._inc("fudai_result_win")
# 提取中奖信息
meta = self._snapshot_fudai()
@@ -553,7 +600,9 @@ class Runner:
self._record_event("fudai_order_success", self._snapshot_fudai())
# 等待开奖(只在设置等待开奖标志时计数,避免重复计数)
# 注意:不要匹配"已经参与,等待开奖",因为那已经在参与成功时计数了
if ("[参与]" in s and "参与成功,设置等待开奖标志" in s) or ("[参与]" in s and "设置等待开奖标志" in s):
if ("[参与]" in s and "参与成功,设置等待开奖标志" in s) or (
"[参与]" in s and "设置等待开奖标志" in s
):
self._inc("fudai_waiting_lottery")
# 提取剩余秒数
meta = self._snapshot_fudai()
@@ -593,7 +642,9 @@ class Runner:
elif "锁定期内" in s:
self._inc("switch_room_locked")
meta_reason = "locked"
self._record_event("switch_room", {"reason": meta_reason, **self._snapshot_fudai()})
self._record_event(
"switch_room", {"reason": meta_reason, **self._snapshot_fudai()}
)
# --- 阶段诊断统计 ---
if "[阶段诊断]" in s or "阶段诊断" in s:
@@ -637,14 +688,21 @@ class Runner:
# 记录耗时较长的操作
if elapsed > 5.0:
self._inc("slow_operation")
self._record_event("slow_operation", {"elapsed_seconds": elapsed, "operation": s[:100]})
self._record_event(
"slow_operation",
{"elapsed_seconds": elapsed, "operation": s[:100]},
)
except Exception:
pass
# --- 详情识别统计 ---
if ("[福袋详情]" in s and "识别" in s) or "识别福袋详情" in s:
self._inc("fudai_detail_read_attempt")
if "识别成功" in s or "识别完成" in s or "read_fudai_detail_once完成(成功)" in s:
if (
"识别成功" in s
or "识别完成" in s
or "read_fudai_detail_once完成(成功)" in s
):
self._inc("fudai_detail_read_success")
# 提取任务数量
meta = {}
@@ -741,7 +799,10 @@ class Runner:
cmd += ["--min-prize-value-yuan", str(params.min_prize_value_yuan)]
# 这些参数是新增可调节项:倒计时太短跳过、参与人数范围
cmd += ["--skip-if-countdown-gt-seconds", str(int(params.skip_if_countdown_gt_seconds or 900))]
cmd += [
"--skip-if-countdown-gt-seconds",
str(int(params.skip_if_countdown_gt_seconds or 900)),
]
if params.reset_after_swipes_enabled:
cmd.append("--reset-after-swipes-enabled")
cmd += ["--reset-after-swipes", str(int(params.reset_after_swipes or 10))]
@@ -771,11 +832,17 @@ class Runner:
else:
cmd.append("--reservation-back-verify-disabled")
if params.reservation_back_swipe_delay > 0:
cmd += ["--reservation-back-swipe-delay", str(params.reservation_back_swipe_delay)]
cmd += [
"--reservation-back-swipe-delay",
str(params.reservation_back_swipe_delay),
]
# 预约抢占最小价值
if params.reservation_preempt_min_value > 0:
cmd += ["--reservation-preempt-min-value", str(params.reservation_preempt_min_value)]
cmd += [
"--reservation-preempt-min-value",
str(params.reservation_preempt_min_value),
]
# 找福袋最大尝试次数
if params.fudai_find_max_attempts > 0:
@@ -794,7 +861,9 @@ class Runner:
cmd.append("--fudai-template-disabled")
# 添加福袋模板匹配阈值参数
cmd.extend(["--fudai-template-threshold", str(params.fudai_template_match_threshold)])
cmd.extend(
["--fudai-template-threshold", str(params.fudai_template_match_threshold)]
)
# 继承当前环境,并确保 adb 在 PATH(即使用户没手动刷新 PATH)
env = os.environ.copy()
@@ -806,7 +875,9 @@ class Runner:
env["PATH"] = adb_dir + os.pathsep + env.get("PATH", "")
env["ADB_EXECUTABLE"] = adb_exe
else:
self._on_line("[警告] 未找到 adb.exe:请安装 platform-tools 或将 adb 加入 PATH")
self._on_line(
"[警告] 未找到 adb.exe:请安装 platform-tools 或将 adb 加入 PATH"
)
try:
p = subprocess.Popen(
@@ -876,7 +947,9 @@ class Runner:
# 如果进程立即退出且没有输出,说明可能有问题
if not has_output and rc != 0:
self._on_line(f"[警告] 进程立即退出,退出码={rc},没有输出")
self._on_line("[提示] 可能的原因:run_cli.py启动失败、导入错误或配置错误")
self._on_line(
"[提示] 可能的原因:run_cli.py启动失败、导入错误或配置错误"
)
else:
self._on_line(f"[进程结束] exit_code={rc}")
except Exception as e: