完善扫描流式预览、成果归档与PLY/STL查看、补扫历史、执行步骤及日志展示,支持局域网访问和改名节点的原始组件识别。修复试运行终止后的占用释放及未采集时重复暂停SDK的问题,增加终止中交互与回归验证。 验证:后端1114项通过、18项既有跳过;前端109项通过,类型检查及构建通过;Python脚本54项通过;模拟扫描设备7组试运行/终止接口回归通过。
48 lines
2.5 KiB
Python
48 lines
2.5 KiB
Python
"""Read-only check of archived PLY/STL download routes; sends no scanner commands."""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import urllib.parse
|
|
import urllib.request
|
|
|
|
from verify_cmvr_native import Client, ROOT, require
|
|
|
|
|
|
def verify(client, execution_id):
|
|
require(execution_id.isdigit(), "Execution ID must be a positive integer")
|
|
result = client.request("GET", "/admin-api/lab/execution/scanner-view/assets",
|
|
query={"executionId": execution_id}, expected=(0,))
|
|
assets = [item for item in result["data"] if Path(item["name"]).suffix.lower() in (".ply", ".stl")]
|
|
require({Path(item["name"]).suffix.lower() for item in assets} == {".ply", ".stl"},
|
|
"This execution must contain both PLY and STL results")
|
|
checked = []
|
|
for asset in assets:
|
|
file_id = asset["fileId"]
|
|
require(file_id.isalnum(), "Unexpected file identifier")
|
|
metadata = ROOT / ".local/artifacts/1" / execution_id / "scanner-files" / (file_id + ".json")
|
|
archived = json.loads(metadata.read_text(encoding="utf-8"))
|
|
path = "/admin-api/lab/execution/scanner-view/asset/" + urllib.parse.quote(file_id)
|
|
path += "?" + urllib.parse.urlencode({"executionId": execution_id})
|
|
request = urllib.request.Request(client.base_url + path, headers={
|
|
"Authorization": "Bearer " + client._token, "tenant-id": "1"})
|
|
digest, length = hashlib.sha256(), 0
|
|
with urllib.request.urlopen(request, timeout=30) as response:
|
|
require(response.status == 200, "File route did not return HTTP 200")
|
|
require("json" not in response.headers.get("content-type", ""), "File route returned an error payload")
|
|
while chunk := response.read(1024 * 1024):
|
|
length += len(chunk)
|
|
digest.update(chunk)
|
|
require(length == archived["bytes"] == asset["bytes"], "Downloaded length differs from archived result")
|
|
require(digest.hexdigest() == archived["sha256"], "Downloaded content differs from archived result")
|
|
checked.append({"name": asset["name"], "bytes": length, "sha256Matches": True})
|
|
return {"executionId": execution_id, "files": checked}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--execution-id", action="append", required=True)
|
|
args = parser.parse_args()
|
|
client = Client().login()
|
|
print(json.dumps({"passed": True, "checks": [verify(client, value) for value in args.execution_id]}, ensure_ascii=False))
|