restore: 恢复 11-06~11-09 本地未提交改动
- libs: 新增 hr_sdk / hotel_report / dingtalk,更新 desktopauto - controlplane-next: SDK 管理模块(controller/entity/migrations)与前端视图 - electron-shell: 插件同步、注册表、runner 调整 - plugins: XQ0035/XQ0041/XQ0042/XQ0045_XQ0046/XQ0048/XQ0076/XQ0078 等版本更新 - tests/tools: 新增 SDK 兼容性检查与打包工具(sdk_pack.py、sdk_compat_check.py)
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
图/文字没匹配到 → None / False(业务上的「不存在」,不是异常)。
|
||||
"""
|
||||
from . import clipboard, colors, fs, keys, ocr, process
|
||||
from ._win32 import click_at
|
||||
from .capture import screenshot
|
||||
from .colors import ColorMatch, diff_ratio, find_colors
|
||||
from .process import (is_running, kill_process, launch, list_processes, open_path,
|
||||
open_url, run_or_open, wait_process)
|
||||
@@ -56,6 +58,8 @@ __all__ = [
|
||||
"Match",
|
||||
"TextItem",
|
||||
"ColorMatch",
|
||||
# 截图 / 坐标点击
|
||||
"screenshot", "click_at",
|
||||
# 识图 / 条件判断 / 等待
|
||||
"find", "find_all", "find_any", "exists", "wait", "click",
|
||||
"wait_gone", "wait_any", "wait_all", "hover", "hover_text",
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""SDK 安装冒烟:纯离线校验导入与识图算法,不碰真实桌面 / 窗口 / 进程 / OCR。
|
||||
|
||||
由 sdk.json.selftest 声明,执行机安装 SDK 后运行 main();
|
||||
开发态全量自测仍用库根 libs/desktopauto/_selftest.py(会检查窗口、进程、OCR 等)。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from . import matcher
|
||||
|
||||
EXPECTED_VERSION = "0.4.0"
|
||||
|
||||
#: 插件实际用到的门面 API,缺失即视为破坏性变更
|
||||
REQUIRED_EXPORTS = (
|
||||
"Screen", "find", "find_all", "exists", "click", "click_at", "hotkey",
|
||||
"paste", "screenshot", "find_windows", "get_window", "Window",
|
||||
"mark", "summarize", "ocr", "fs", "keys", "sleep",
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
import desktopauto
|
||||
|
||||
version = str(getattr(desktopauto, "__version__", ""))
|
||||
if version != EXPECTED_VERSION:
|
||||
raise AssertionError(f"版本不一致:__version__={version},期望 {EXPECTED_VERSION}")
|
||||
|
||||
missing = [n for n in REQUIRED_EXPORTS if not hasattr(desktopauto, n)]
|
||||
if missing:
|
||||
raise AssertionError(f"门面 API 缺失:{missing}")
|
||||
|
||||
# 合成图 + 同款模板:只跑内存里的匹配算法,不截图、不点击
|
||||
img = np.full((120, 200, 3), 240, dtype=np.uint8)
|
||||
img[20:50, 30:90] = (40, 120, 200)
|
||||
tpl = img[20:50, 30:90].copy()
|
||||
hits = matcher.match_in(img, tpl, threshold=0.9)
|
||||
if not any(h.left == 30 and h.top == 20 for h in hits):
|
||||
raise AssertionError(f"识图未命中预期坐标:{[(h.left, h.top) for h in hits]}")
|
||||
hit = hits[0]
|
||||
if hit.center != (hit.left + 30, hit.top + 15):
|
||||
raise AssertionError(f"中心点换算错误:{hit.center}")
|
||||
|
||||
print(f"[OK] desktopauto {version} SDK 冒烟通过({len(REQUIRED_EXPORTS)} 项门面 API)")
|
||||
return 0
|
||||
Reference in New Issue
Block a user