- Removed excessive blank lines from multiple Python scripts and configuration files to improve readability and maintainability. - Ensured consistent formatting across the project, contributing to a more organized codebase. - Added new files for testing and analysis, including `test_screenshot_error_handling.py` and `test_screenshot_reuse_optimization.py`, to improve testing coverage and functionality.
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
测试截图服务修复效果
|
|
"""
|
|
|
|
import time
|
|
import sys
|
|
import os
|
|
|
|
# 添加项目根目录到路径
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
def test_service_startup():
|
|
"""测试截图服务启动"""
|
|
print("测试截图服务启动修复...")
|
|
|
|
# 模拟启动过程
|
|
from douyin.core.douyin_fudai import fudai_analyse
|
|
|
|
# 创建分析器实例
|
|
analyser_instance = fudai_analyse()
|
|
|
|
print("启动fudai_choujiang(只运行几秒钟测试服务启动)...")
|
|
|
|
try:
|
|
# 设置设备ID(需要根据实际情况修改)
|
|
device_id = "emulator-5554" # 或者其他设备ID
|
|
|
|
# 启动服务(只运行5秒)
|
|
analyser_instance.fudai_choujiang(
|
|
device_id=device_id,
|
|
wait_minutes=0, # 不等待,直接测试启动
|
|
)
|
|
|
|
except KeyboardInterrupt:
|
|
print("测试被中断")
|
|
except Exception as e:
|
|
print(f"测试过程中出现异常: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
# 检查服务状态
|
|
print("\n检查服务状态:")
|
|
from operations.screenshot_service import ScreenshotService
|
|
service = ScreenshotService.get_instance()
|
|
info = service.get_cache_info()
|
|
|
|
print(f"服务运行中: {info['running']}")
|
|
print(f"设备ID: {info['device_id']}")
|
|
print(f"后台线程: {'运行中' if hasattr(service, '_thread') and service._thread and service._thread.is_alive() else '未运行'}")
|
|
|
|
# 停止服务
|
|
if service.is_running():
|
|
service.stop()
|
|
print("服务已停止")
|
|
|
|
if __name__ == "__main__":
|
|
test_service_startup()
|