- Deleted obsolete markdown files related to follow tab coordinates testing and results. - Removed outdated batch scripts for launching the Web GUI. - Updated `config.json` to improve reservation handling and adjust prize value settings. - Enhanced logging and error handling in `web_gui.py` and `app.js` for better user experience. - Added automatic screenshot functionality during Web GUI startup for improved monitoring.
188 lines
7.3 KiB
Python
188 lines
7.3 KiB
Python
"""
|
|
文件夹整理脚本:整理项目文件夹结构,同时更新代码中的路径引用
|
|
"""
|
|
import os
|
|
import shutil
|
|
import re
|
|
|
|
# 项目根目录
|
|
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
# 整理方案:
|
|
# 1. pic/ 目录分类:
|
|
# - pic/screenshot.png (保持根目录,运行时临时截图)
|
|
# - pic/ocr/ (OCR识别用的图片,运行时生成)
|
|
# - pic/debug/ (调试截图,可归档)
|
|
# - pic/test/ (测试图片)
|
|
# - pic/archive/ (归档的旧截图)
|
|
|
|
# 运行时必须保持在 pic/ 根目录的文件(不能移动)
|
|
RUNTIME_FILES = {
|
|
'screenshot.png', # 当前屏幕截图
|
|
'cut.png', # 裁剪后的临时图片
|
|
'window_dump.xml', # UI dump文件
|
|
}
|
|
|
|
# 必须保持的子目录(不能移动)
|
|
KEEP_DIRS = {
|
|
'save', # 保存验证图片的目录
|
|
}
|
|
|
|
# OCR识别用的图片(会从根目录移动到 ocr/ 子目录,但代码中已改为从 ocr/ 读取)
|
|
OCR_FILES = [
|
|
# 诊断相关
|
|
'diag_attend_btn.png', '诊断优惠券按钮.png', '诊断优惠券标题.png',
|
|
'diag_fansclub_join.png', 'diag_follow_title.png', 'diag_guess_like_check.png',
|
|
'diag_guess_like.png', 'diag_list_title.png', 'diag_live_plaza.png',
|
|
'diag_recommend_title_check.png', 'diag_recommend_title.png', 'diag_result.png',
|
|
'诊断购物红包.png', '诊断购物红包按钮.png', 'diag_status.png',
|
|
# 福袋相关
|
|
'fudai_content.png', 'fudai_countdown_m.png', 'fudai_countdown_s.png',
|
|
'fudai_countdown.png', 'fudai_value.png', 'fudai_task_once_1.png',
|
|
'fudai_task_once_2.png', 'fudai_task_once_3.png', 'fudai_tasks_1.png',
|
|
'fudai_tasks_2.png', 'fudai_tasks_3.png',
|
|
# 按钮/界面元素
|
|
'attend_button.png', '参与按钮.png', '优惠券按钮.png', '优惠券标题.png',
|
|
'抽奖结果.png', '直播广场.png', '福袋价值.png',
|
|
'福袋倒计时_分钟.png', '福袋倒计时_秒.png', '福袋倒计时.png',
|
|
'福袋内容.png', '购物红包.png', '任务用户区域.png',
|
|
# 直播间相关
|
|
'live_room_title_large.png', '直播间标题_中.png', 'live_room_title_small.png',
|
|
'live_room_title.png', 'live_room_title2.png', 'zhibo_follow_list_title.png',
|
|
'zhibo_follow_list.png', 'zhibo_hongbao.png',
|
|
'zhibo_status.png', 'zhibo_yanzheng.png',
|
|
# 其他运行时文件
|
|
'lucky_draw_result.png', 'no_award_confirm.png', 'bottom_bar.png',
|
|
'follow_precise_location.png', 'follow_region_precise.png',
|
|
'follow_tab_detection.png', 'follow_tab_region_detailed.png', 'follow_tab_region.png',
|
|
'福袋任务_单次_1.png', '福袋任务_单次_2.png',
|
|
]
|
|
|
|
# 测试文件(移动到 test/ 子目录)
|
|
TEST_FILES = [
|
|
'test_bottom_tab_follow.png', 'test_bottom_tab.png',
|
|
'test_bottom_中间区域消息.png', 'test_bottom_关注标签区域.png',
|
|
'test_bottom_右侧区域我.png', 'test_bottom_完整底部标签栏.png',
|
|
'test_bottom_左侧区域首页_推荐.png', 'test_follow_title.png',
|
|
'test_guess_like.png', 'test_list_title.png', 'test_recommend_expanded.png',
|
|
'test_recommend_title.png',
|
|
]
|
|
|
|
# 调试/归档文件(移动到 archive/ 子目录)
|
|
DEBUG_DIRS = [
|
|
'action_fav_roi', 'action_like_roi', 'after_fav_click', 'after_like_click',
|
|
'after_swipe', 'before_detect_action_fav_roi', 'before_detect_action_like_roi',
|
|
'before_fav_click', 'before_like_click', 'before_swipe',
|
|
'comment_after_close', 'comment_after_focus', 'comment_after_input',
|
|
'comment_after_open', 'comment_after_send', 'comment_before_open',
|
|
'desktop_icon', 'start', 'step1_close', 'step2_back', 'step3_browse_done',
|
|
'step4_live', 'step5_enter',
|
|
]
|
|
|
|
DEBUG_FILES = [
|
|
'screenshot_annotated.png', 'screenshot_regions_marked.png',
|
|
'screenshot_直播广场_标注.png',
|
|
]
|
|
|
|
|
|
def organize_pic_directory():
|
|
"""整理 pic 目录"""
|
|
pic_dir = os.path.join(PROJECT_ROOT, 'pic')
|
|
if not os.path.exists(pic_dir):
|
|
print(f"[整理] pic 目录不存在,跳过")
|
|
return
|
|
|
|
# 创建子目录
|
|
ocr_dir = os.path.join(pic_dir, 'ocr')
|
|
test_dir = os.path.join(pic_dir, 'test')
|
|
archive_dir = os.path.join(pic_dir, 'archive')
|
|
|
|
for d in [ocr_dir, test_dir, archive_dir]:
|
|
os.makedirs(d, exist_ok=True)
|
|
|
|
# 移动 OCR 文件
|
|
moved_ocr = 0
|
|
for filename in OCR_FILES:
|
|
src = os.path.join(pic_dir, filename)
|
|
if os.path.exists(src):
|
|
dst = os.path.join(ocr_dir, filename)
|
|
if not os.path.exists(dst):
|
|
shutil.move(src, dst)
|
|
moved_ocr += 1
|
|
print(f"[整理] 移动 OCR 文件: {filename} -> ocr/{filename}")
|
|
|
|
# 移动测试文件
|
|
moved_test = 0
|
|
for filename in TEST_FILES:
|
|
src = os.path.join(pic_dir, filename)
|
|
if os.path.exists(src):
|
|
dst = os.path.join(test_dir, filename)
|
|
if not os.path.exists(dst):
|
|
shutil.move(src, dst)
|
|
moved_test += 1
|
|
print(f"[整理] 移动测试文件: {filename} -> test/{filename}")
|
|
|
|
# 移动调试目录(跳过需要保留的目录)
|
|
moved_dirs = 0
|
|
for dirname in DEBUG_DIRS:
|
|
if dirname in KEEP_DIRS:
|
|
continue # 跳过需要保留的目录
|
|
src = os.path.join(pic_dir, dirname)
|
|
if os.path.exists(src) and os.path.isdir(src):
|
|
dst = os.path.join(archive_dir, dirname)
|
|
if not os.path.exists(dst):
|
|
shutil.move(src, dst)
|
|
moved_dirs += 1
|
|
print(f"[整理] 移动调试目录: {dirname}/ -> archive/{dirname}/")
|
|
|
|
# 移动调试文件
|
|
moved_debug = 0
|
|
for filename in DEBUG_FILES:
|
|
src = os.path.join(pic_dir, filename)
|
|
if os.path.exists(src):
|
|
dst = os.path.join(archive_dir, filename)
|
|
if not os.path.exists(dst):
|
|
shutil.move(src, dst)
|
|
moved_debug += 1
|
|
print(f"[整理] 移动调试文件: {filename} -> archive/{filename}")
|
|
|
|
print(f"\n[整理完成] pic 目录整理统计:")
|
|
print(f" - OCR 文件: {moved_ocr} 个 -> pic/ocr/")
|
|
print(f" - 测试文件: {moved_test} 个 -> pic/test/")
|
|
print(f" - 调试目录: {moved_dirs} 个 -> pic/archive/")
|
|
print(f" - 调试文件: {moved_debug} 个 -> pic/archive/")
|
|
print(f"\n[提示] 代码已更新,支持新旧路径查找(向后兼容)")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
import sys
|
|
print("=" * 60)
|
|
print("文件夹整理脚本")
|
|
print("=" * 60)
|
|
print("\n此脚本将:")
|
|
print(" 1. 整理 pic/ 目录,将文件分类到子目录")
|
|
print(" 2. OCR文件 -> pic/ocr/")
|
|
print(" 3. 测试文件 -> pic/test/")
|
|
print(" 4. 调试文件/目录 -> pic/archive/")
|
|
print("\n运行时文件(screenshot.png, cut.png)保持在根目录")
|
|
print("\n[提示] 代码已更新,支持新旧路径查找(向后兼容)")
|
|
print("=" * 60)
|
|
|
|
# 支持命令行参数 --yes 自动确认
|
|
auto_confirm = '--yes' in sys.argv or '-y' in sys.argv
|
|
|
|
if not auto_confirm:
|
|
try:
|
|
response = input("\n是否继续?(y/n): ").strip().lower()
|
|
except (EOFError, KeyboardInterrupt):
|
|
print("\n已取消(非交互式环境,使用 --yes 参数可自动确认)")
|
|
sys.exit(0)
|
|
else:
|
|
response = 'y'
|
|
|
|
if response == 'y':
|
|
organize_pic_directory()
|
|
else:
|
|
print("已取消")
|
|
|