Capture M16 gap execution artifacts
This commit is contained in:
104
tools/web/check-action-channel-view-pick-desktop.py
Normal file
104
tools/web/check-action-channel-view-pick-desktop.py
Normal file
@@ -0,0 +1,104 @@
|
||||
#!/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("WebGapAnimChannelViewPickObject")
|
||||
if obj is None or obj.animation_data is None or obj.animation_data.action is None:
|
||||
raise RuntimeError("WebGapAnimChannelViewPickObject 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 view_report():
|
||||
area = None
|
||||
for screen in bpy.data.screens:
|
||||
area = next(
|
||||
(candidate for candidate in screen.areas
|
||||
if candidate.type == "DOPESHEET_EDITOR" and candidate.spaces.active.ui_mode == "ACTION" and candidate.height >= 200),
|
||||
None,
|
||||
)
|
||||
if area is not None:
|
||||
break
|
||||
if area is None:
|
||||
raise RuntimeError("Action Editor area is missing")
|
||||
region = next((candidate for candidate in area.regions if candidate.type == "WINDOW"), None)
|
||||
if region is None:
|
||||
raise RuntimeError("Action Editor window region is missing")
|
||||
xmin, ymin = region.view2d.region_to_view(0, 0)
|
||||
xmax, ymax = region.view2d.region_to_view(region.width - 1, region.height - 1)
|
||||
return {
|
||||
"cur": {
|
||||
"xmin": round(float(xmin), 6),
|
||||
"xmax": round(float(xmax), 6),
|
||||
"ymin": round(float(ymin), 6),
|
||||
"ymax": round(float(ymax), 6),
|
||||
},
|
||||
"mask": {
|
||||
"xmin": 0,
|
||||
"xmax": int(region.width - 1),
|
||||
"ymin": 0,
|
||||
"ymax": int(region.height - 1),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def report_state():
|
||||
return {"action": action_report(), "view2d": view_report()}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-action-channel-view-pick-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_state()
|
||||
if before["action"]["name"] != "WebGapAnimChannelViewPickObjectAction":
|
||||
raise RuntimeError(f"unexpected anim.channel_view_pick action: {before}")
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="m16-anim-channel-view-pick-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=True)
|
||||
after = report_state()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError("anim.channel_view_pick save/reopen drift")
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"task": "M16-GAP-00152",
|
||||
"operation": "ANIM_CHANNEL_VIEW_PICK_DESKTOP",
|
||||
"fixture": str(fixture),
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"action": after["action"],
|
||||
"view2d": after["view2d"],
|
||||
"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-channel-view-pick-desktop-ok view2d=exact saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user