Files
workinf_Blender_Wasm/tools/web/check-scene-desktop.py
mes123456 10640aeb3c
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
Govern task context and advance execution pointer
2026-08-20 06:02:43 -04:00

55 lines
2.2 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def report():
scene = bpy.data.scenes.get("WebGapScene")
if scene is None:
raise RuntimeError("WebGapScene is missing")
return {
"id": "scene:" + scene.name,
"name": scene.name,
"frameCurrent": int(scene.frame_current),
"frameStart": int(scene.frame_start),
"frameEnd": int(scene.frame_end),
"fps": round(float(scene.render.fps), 6),
"fpsBase": round(float(scene.render.fps_base), 6),
"unitSystem": {"NONE": 0, "METRIC": 1, "IMPERIAL": 2}.get(scene.unit_settings.system, -1),
"unitScale": round(float(scene.unit_settings.scale_length), 6),
"renderEngine": scene.render.engine,
}
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-scene-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 = report()
descriptor, temporary = tempfile.mkstemp(prefix="m16-scene-reopen-", suffix=".blend", dir=fixture.parent)
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 = report()
finally:
pathlib.Path(temporary).unlink(missing_ok=True)
if before != after:
raise RuntimeError(f"scene save/reopen drift: {before} != {after}")
value = {"schemaVersion": 1, "task": "M16-GAP-00020", "operation": "SCENE_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "scene": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string}
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print(f"scene-desktop-ok id={after['id']} frames={after['frameStart']}-{after['frameEnd']} saveReopen=exact")
if __name__ == "__main__":
main()