整理项目文件分类
This commit is contained in:
1 parent
38e2b399d4
commit
1fdec7a548
20 files changed
+35
-13
No files matched your search
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python3
|
||||
"""项目自检脚本:检查 action_logger 初始化与 analyser._log_kv 绑定。
|
||||
|
||||
用法: 在与项目相同的 Python 环境中运行:
|
||||
python tools/check_action_logger.py
|
||||
"""
|
||||
import logging
|
||||
import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
|
||||
import sys
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
from douyin.logging import action_logger, douyin_logging_wrapper
|
||||
from douyin.core.douyin_fudai import fudai_analyse
|
||||
import path_config
|
||||
|
||||
|
||||
def safe_repr(obj):
|
||||
try:
|
||||
return repr(obj)
|
||||
except Exception:
|
||||
return "<unreprable>"
|
||||
|
||||
|
||||
def main():
|
||||
print("=== action_logger / handler 状态 ===")
|
||||
try:
|
||||
al = logging.getLogger("action_logger")
|
||||
handlers = al.handlers
|
||||
print(
|
||||
"logger 'action_logger' handlers:",
|
||||
[(type(h).__name__, getattr(h, "baseFilename", None)) for h in handlers],
|
||||
)
|
||||
except Exception:
|
||||
print("获取 action_logger 失败:")
|
||||
traceback.print_exc()
|
||||
|
||||
print("\n=== action_logger 模块队列/监听器 ===")
|
||||
try:
|
||||
q = getattr(action_logger, "_log_queue", None)
|
||||
l = getattr(action_logger, "_queue_listener", None)
|
||||
print("_log_queue:", type(q).__name__ if q is not None else None)
|
||||
print("_queue_listener:", type(l).__name__ if l is not None else None)
|
||||
if l is not None:
|
||||
# QueueListener has method 'is_alive' if it's a Thread subclass; otherwise skip
|
||||
alive = getattr(l, "is_alive", lambda: False)()
|
||||
print("listener is_alive:", alive)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
print("\n=== actions.log 路径与权限 ===")
|
||||
try:
|
||||
path = path_config.get_actions_log_path()
|
||||
print("actions.log path:", path)
|
||||
try:
|
||||
with open(path, "a", encoding="utf-8") as f:
|
||||
f.write(f"#check {time.time()}\n")
|
||||
print("已向 actions.log 追加一行(权限与磁盘检查通过)")
|
||||
except Exception as e:
|
||||
print("写入 actions.log 失败:", e)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
print("\n=== analyser._log_kv 绑定检查与试写 ===")
|
||||
try:
|
||||
a = fudai_analyse()
|
||||
print("analyser._log_kv repr:", safe_repr(a._log_kv))
|
||||
try:
|
||||
a._log_kv("check_point", "self_check", detail="test_write")
|
||||
print(
|
||||
"已调用 analyser._log_kv(...). 请查看 actions.log 是否包含该条目(或等待几秒队列刷新)"
|
||||
)
|
||||
except Exception as e:
|
||||
print("调用 analyser._log_kv 失败:", e)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
print("\n检查完成。")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,14 @@
|
||||
from douyin.core.douyin_fudai import fudai_analyse
|
||||
from path_config import get_like_template_path, get_fav_template_path
|
||||
|
||||
a = fudai_analyse()
|
||||
print("default threshold", a.yanghao_icon_match_threshold)
|
||||
like_roi = "pic/roi_test_like_20260104000913_1767456556.png"
|
||||
fav_roi = "pic/roi_test_fav_20260104000916_1767456559.png"
|
||||
like_tpl = get_like_template_path()
|
||||
fav_tpl = get_fav_template_path()
|
||||
print("Like match (default):", a._match_icon_template(like_roi, like_tpl))
|
||||
print("Fav match (default):", a._match_icon_template(fav_roi, fav_tpl))
|
||||
a.yanghao_icon_match_threshold = 0.5
|
||||
print("Like match (thr=0.5):", a._match_icon_template(like_roi, like_tpl))
|
||||
print("Fav match (thr=0.5):", a._match_icon_template(fav_roi, fav_tpl))
|
||||
Reference in new issue
Block a user