Files
workinf_Blender_Wasm/tools/web/check-action-stash-desktop.py
mes123456 46c9ebfcb6
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Capture M16 gap execution artifacts
2026-08-21 21:09:40 -04:00

66 lines
2.5 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def nla_report():
obj = bpy.data.objects.get("WebGapStashObject")
if obj is None or obj.animation_data is None:
raise RuntimeError("WebGapStashObject animation data is missing")
tracks = []
for track in obj.animation_data.nla_tracks:
tracks.append({
"name": track.name,
"strips": [{
"name": strip.name,
"action": strip.action.name if strip.action else None,
"frameStart": round(float(strip.frame_start), 6),
"frameEnd": round(float(strip.frame_end), 6),
} for strip in track.strips],
})
return {"activeAction": obj.animation_data.action.name if obj.animation_data.action else None, "tracks": tracks}
def main():
arguments = sys.argv[sys.argv.index("--") + 1:]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-action-stash-desktop.py -- FIXTURE REPORT")
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
before = nla_report()
if before["activeAction"] is not None or len(before["tracks"]) != 1 or len(before["tracks"][0]["strips"]) != 1:
raise RuntimeError(f"unexpected action.stash result: {before}")
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-stash-reopen-", suffix=".blend")
os.close(descriptor)
try:
bpy.ops.wm.save_as_mainfile(filepath=temporary, check_existing=False, compress=True)
bpy.ops.wm.open_mainfile(filepath=temporary, load_ui=False)
after = nla_report()
finally:
pathlib.Path(temporary).unlink(missing_ok=True)
if before != after:
raise RuntimeError(f"action.stash save/reopen drift: {before} != {after}")
report = {
"schemaVersion": 1,
"task": "M16-GAP-00144",
"operation": "ACTION_STASH_DESKTOP",
"fixture": str(fixture),
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
"nla": after,
"saveReopen": "EXACT",
"blenderVersion": bpy.app.version_string,
}
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print("action-stash-desktop-ok tracks=1 strips=1 activeAction=none saveReopen=exact")
if __name__ == "__main__":
main()