feat: add Android task file evidence and finalize plugin design
This commit is contained in:
1 parent
96fedc816f
commit
72ff342605
20 files changed
+1005
-35
No files matched your search
@@ -792,6 +792,22 @@ def session_videos(report: dict) -> list[tuple[Path, str]]:
|
||||
return [(path, f"{i:04d}_{path.parent.name}_{path.name}") for i, path in enumerate(paths, 1)]
|
||||
|
||||
|
||||
def session_artifacts(report: dict) -> list[tuple[Path, str]]:
|
||||
"""Only completed, task-owned Android files; never follow external links."""
|
||||
traces = TRACES_PATH.resolve()
|
||||
root = traces / identifier(report["id"]) / "artifacts" / "android"
|
||||
if not root.is_dir() or root.resolve() != root:
|
||||
return []
|
||||
return [
|
||||
(path, path.name)
|
||||
for path in sorted(root.iterdir())
|
||||
if path.is_file()
|
||||
and not path.is_symlink()
|
||||
and not path.name.startswith(".artemis-")
|
||||
and path.resolve().parent == root.resolve()
|
||||
]
|
||||
|
||||
|
||||
def export_session_media(session_id: str, kind: str) -> Path:
|
||||
if kind not in {"screenshots", "video", "all"}:
|
||||
raise ValueError("不支持的下载类型")
|
||||
@@ -801,6 +817,7 @@ def export_session_media(session_id: str, kind: str) -> Path:
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
images = session_screenshots(report) if kind in {"screenshots", "all"} else []
|
||||
videos = session_videos(report) if kind in {"video", "all"} else []
|
||||
artifacts = session_artifacts(report) if kind == "all" else []
|
||||
if kind == "video" and not videos:
|
||||
raise ValueError("此任务没有已保存的录屏")
|
||||
if kind == "screenshots" and not images:
|
||||
@@ -814,6 +831,7 @@ def export_session_media(session_id: str, kind: str) -> Path:
|
||||
"verdict": report["verdict"],
|
||||
"screenshots": [name for _, name in images],
|
||||
"videos": [name for _, name in videos],
|
||||
"artifacts": [name for _, name in artifacts],
|
||||
"note": "录屏按时间顺序分段;暂停期间未占用设备,也未录制其他任务。",
|
||||
}
|
||||
prefix = archive_case_name(report) + "/" if kind == "all" else ""
|
||||
@@ -825,6 +843,8 @@ def export_session_media(session_id: str, kind: str) -> Path:
|
||||
archive.write(source, f"{prefix}步骤截图/{name}")
|
||||
for source, name in videos:
|
||||
archive.write(source, f"{prefix}任务录屏/{name}")
|
||||
for source, name in artifacts:
|
||||
archive.write(source, f"{prefix}任务文件/安卓/{name}")
|
||||
archive.writestr(
|
||||
prefix + "文件清单.json", json.dumps(manifest, ensure_ascii=False, indent=2)
|
||||
)
|
||||
@@ -882,6 +902,8 @@ def export_batch(batch_id: str, progress: Callable[[int, int, str], None] | None
|
||||
archive.write(source, f"{prefix}/步骤截图/{name}")
|
||||
for source, name in session_videos(report):
|
||||
archive.write(source, f"{prefix}/任务录屏/{name}")
|
||||
for source, name in session_artifacts(report):
|
||||
archive.write(source, f"{prefix}/任务文件/安卓/{name}")
|
||||
if progress:
|
||||
progress(number, len(records), f"已打包任务 {number}/{len(records)}")
|
||||
if progress:
|
||||
|
||||
Reference in new issue
Block a user