23 lines
1.6 KiB
Python
23 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
import hashlib, json, os, pathlib, sys, tempfile
|
|
import bpy
|
|
|
|
def report():
|
|
workspace = bpy.data.workspaces.get("WebGapWorkspace")
|
|
if workspace is None: raise RuntimeError("WebGapWorkspace is missing")
|
|
return {"id": "workspace:" + workspace.name, "name": workspace.name, "screenCount": len(workspace.screens)}
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 2: raise SystemExit("usage: blender -b --python check-workspace-desktop.py -- FIXTURE REPORT")
|
|
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
|
|
bpy.ops.wm.open_mainfile(filepath=str(fixture)); before = report()
|
|
descriptor, temporary = tempfile.mkstemp(prefix="m16-workspace-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); after = report()
|
|
finally: pathlib.Path(temporary).unlink(missing_ok=True)
|
|
if before != after: raise RuntimeError(f"workspace save/reopen drift: {before} != {after}")
|
|
value = {"schemaVersion": 1, "task": "M16-GAP-00028", "operation": "WORKSPACE_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "workspace": 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"workspace-desktop-ok id={after['id']} saveReopen=exact")
|
|
if __name__ == "__main__": main()
|