chore: Clean up blank lines and enhance code organization
- 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.
This commit is contained in:
1 parent
7db9864848
commit
478ae69052
85 files changed
+2879
-383
No files matched your search
@@ -488,18 +488,29 @@ class underlying_operations:
|
||||
返回:
|
||||
是否成功获取截图
|
||||
"""
|
||||
# 如果启用服务模式,使用后台截图服务
|
||||
# 如果启用服务模式,使用后台截图服务;若服务不可用或返回 False,则回退到直接截图
|
||||
if use_service:
|
||||
try:
|
||||
from operations.screenshot_service import ScreenshotService
|
||||
service = ScreenshotService.get_instance()
|
||||
return service.get_screenshot(device_id, force=False)
|
||||
try:
|
||||
service_result = service.get_screenshot(device_id, force=False)
|
||||
if service_result:
|
||||
return True
|
||||
else:
|
||||
from datetime import datetime
|
||||
timetag = datetime.now().strftime("%H:%M:%S")
|
||||
print(f"[{timetag}] [截图操作] 后台服务未提供有效截图,回退到直接截图")
|
||||
# 不 return,这里继续走直接截图逻辑
|
||||
except Exception as e:
|
||||
from datetime import datetime
|
||||
timetag = datetime.now().strftime("%H:%M:%S")
|
||||
print(f"[{timetag}] [截图操作] 调用后台服务异常,回退到直接截图: {e}")
|
||||
except Exception as e:
|
||||
# 服务不可用时,回退到直接截图
|
||||
from datetime import datetime
|
||||
timetag = datetime.now().strftime("%H:%M:%S")
|
||||
print(f"[{timetag}] [截图操作] ⚠️ 服务模式失败,回退到直接截图: {e}")
|
||||
|
||||
print(f"[{timetag}] [截图操作] 服务模式不可用,回退到直接截图: {e}")
|
||||
|
||||
# 原有的直接截图逻辑(保持向后兼容)
|
||||
return self._get_screenshot_direct(device_id, path)
|
||||
|
||||
|
||||
Reference in new issue
Block a user