Govern task context and advance execution pointer
This commit is contained in:
49
tools/web/check-screen-desktop.py
Normal file
49
tools/web/check-screen-desktop.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def report():
|
||||
screen = bpy.data.screens.get("WebGapScreen")
|
||||
if screen is None:
|
||||
raise RuntimeError("WebGapScreen is missing")
|
||||
return {
|
||||
"id": "screen:" + screen.name,
|
||||
"name": screen.name,
|
||||
"areaCount": len(screen.areas),
|
||||
"editors": sorted(area.type for area in screen.areas),
|
||||
"regionCount": sum(len(area.regions) for area in screen.areas),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-screen-desktop.py -- FIXTURE REPORT")
|
||||
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
|
||||
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=True)
|
||||
before = report()
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="m16-screen-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=True)
|
||||
after = report()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError(f"screen save/reopen drift: {before} != {after}")
|
||||
value = {"schemaVersion": 1, "task": "M16-GAP-00021", "operation": "SCREEN_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "screen": 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"screen-desktop-ok id={after['id']} areas={after['areaCount']} saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user