Capture M16 gap execution artifacts
This commit is contained in:
78
tools/web/check-action-channels-clean-empty-desktop.py
Normal file
78
tools/web/check-action-channels-clean-empty-desktop.py
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def action_report():
|
||||
obj = bpy.data.objects.get("WebGapAnimChannelsCleanKeepObject")
|
||||
if obj is None or obj.animation_data is None or obj.animation_data.action is None:
|
||||
raise RuntimeError("WebGapAnimChannelsCleanKeepObject Action is missing")
|
||||
action = obj.animation_data.action
|
||||
channels = []
|
||||
for layer in action.layers:
|
||||
for strip in layer.strips:
|
||||
for bag in strip.channelbags:
|
||||
for curve in bag.fcurves:
|
||||
channels.append({
|
||||
"path": curve.data_path,
|
||||
"index": curve.array_index,
|
||||
"frames": [round(float(keyframe.co.x), 6) for keyframe in curve.keyframe_points],
|
||||
})
|
||||
channels.sort(key=lambda value: (value["path"], value["index"]))
|
||||
return {"name": action.name, "channels": channels}
|
||||
|
||||
|
||||
def state_report():
|
||||
empty = bpy.data.objects.get("WebGapAnimChannelsCleanEmptyObject")
|
||||
keep = bpy.data.objects.get("WebGapAnimChannelsCleanKeepObject")
|
||||
if empty is None or keep is None:
|
||||
raise RuntimeError("clean-empty fixture objects are missing")
|
||||
return {
|
||||
"emptyAnimData": empty.animation_data is not None,
|
||||
"keepAction": action_report(),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-action-channels-clean-empty-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 = state_report()
|
||||
if before["emptyAnimData"] or len(before["keepAction"]["channels"]) != 3:
|
||||
raise RuntimeError(f"unexpected anim.channels_clean_empty result: {before}")
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="m16-anim-channels-clean-empty-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 = state_report()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError("anim.channels_clean_empty save/reopen drift")
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"task": "M16-GAP-00154",
|
||||
"operation": "ANIM_CHANNELS_CLEAN_EMPTY_DESKTOP",
|
||||
"fixture": str(fixture),
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"emptyAnimDataRemoved": True,
|
||||
"keepAction": after["keepAction"],
|
||||
"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("anim-channels-clean-empty-desktop-ok removedEmpty=true keepChannels=3 saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user