Files
workinf_Blender_Wasm/tools/web/check-action-copy-driver-button-desktop.py
mes123456 46c9ebfcb6
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Capture M16 gap execution artifacts
2026-08-21 21:09:40 -04:00

100 lines
3.7 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def driver_report(obj):
if obj is None or obj.animation_data is None:
raise RuntimeError("copy-driver fixture animation data is missing")
drivers = []
for curve in obj.animation_data.drivers:
driver = curve.driver
drivers.append({
"path": curve.data_path,
"index": curve.array_index,
"expression": driver.expression if driver else "",
"type": driver.type if driver else "",
"variableCount": len(driver.variables) if driver else 0,
})
drivers.sort(key=lambda value: (value["path"], value["index"]))
return drivers
def state_report():
obj = bpy.data.objects.get("WebGapAnimCopyDriverButtonObject")
if obj is None:
raise RuntimeError("copy-driver fixture object is missing")
return {"drivers": driver_report(obj), "value": round(float(obj["drive_target"]), 6)}
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-action-copy-driver-button-desktop.py -- FIXTURE REPORT")
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
output.unlink(missing_ok=True)
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
before = state_report()
expected = [{
"path": '["drive_target"]',
"index": 0,
"expression": "frame * 2.0 + 1.0",
"type": "SCRIPTED",
"variableCount": 0,
}]
if before["drivers"] != expected:
raise RuntimeError(f"unexpected copy_driver_button source driver: {before}")
window = bpy.context.window
screen = window.screen
area = next(candidate for candidate in screen.areas if candidate.type == "PROPERTIES")
region = next(candidate for candidate in area.regions if candidate.type == "WINDOW")
with bpy.context.temp_override(window=window, screen=screen, area=area, region=region):
result = bpy.ops.anim.copy_driver_button()
if result != {"CANCELLED"}:
raise RuntimeError(f"unexpected ANIM_OT_copy_driver_button result: {result}")
after_cancel = state_report()
if after_cancel != before:
raise RuntimeError(f"copy_driver_button cancellation changed Main data: {before} != {after_cancel}")
descriptor, temporary = tempfile.mkstemp(prefix="m16-anim-copy-driver-button-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.copy_driver_button save/reopen drift")
report = {
"schemaVersion": 1,
"task": "M16-GAP-00173",
"operation": "ANIM_COPY_DRIVER_BUTTON_DESKTOP",
"fixture": str(fixture),
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
"drivers": after["drivers"],
"value": after["value"],
"operatorStatus": "CANCELLED",
"mainMutation": "NONE",
"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(f"anim-copy-driver-button-desktop-ok drivers=1 status={report['operatorStatus']} mainMutation=none saveReopen=exact")
if __name__ == "__main__":
try:
main()
except Exception as error:
print(f"anim-copy-driver-button-desktop-failed: {error}")
raise SystemExit(1)