Govern task context and advance execution pointer
This commit is contained in:
51
tools/web/check-action-desktop.py
Normal file
51
tools/web/check-action-desktop.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read the Action gap fixture with Blender 5.2 and verify save/reopen stability."""
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
import os
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def action_report():
|
||||
actions = []
|
||||
for action in sorted(bpy.data.actions, key=lambda value: value.name):
|
||||
channels = []
|
||||
for layer in action.layers:
|
||||
for strip in layer.strips:
|
||||
for bag in strip.channelbags:
|
||||
channels.extend((curve.data_path, curve.array_index, len(curve.keyframe_points)) for curve in bag.fcurves)
|
||||
actions.append({"name": action.name, "frameRange": [round(float(value), 6) for value in action.frame_range], "channels": sorted(channels)})
|
||||
return actions
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(args) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-action-desktop.py -- FIXTURE REPORT")
|
||||
fixture, report_path = (pathlib.Path(value).resolve() for value in args)
|
||||
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
|
||||
before = action_report()
|
||||
if len(before) != 1 or before[0]["name"] != "AnimatedObjectAction":
|
||||
raise RuntimeError(f"unexpected Action inventory: {before}")
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-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 = action_report()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError(f"Action save/reopen drift: before={before} after={after}")
|
||||
report = {"schemaVersion": 1, "task": "M16-GAP-00001", "operation": "ACTION_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "actions": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string}
|
||||
report_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
report_path.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
print(f"action-desktop-ok actions={len(after)} channels={len(after[0]['channels'])} saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user