Files
workinf_Blender_Wasm/tools/web/check-speaker-desktop.py
mes123456 10640aeb3c
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
Govern task context and advance execution pointer
2026-08-20 06:02:43 -04:00

58 lines
2.3 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def report():
speaker = bpy.data.speakers.get("WebGapSpeaker")
if speaker is None:
raise RuntimeError("WebGapSpeaker is missing")
return {
"id": "speaker:" + speaker.name,
"name": speaker.name,
"soundId": "sound:" + speaker.sound.name if speaker.sound else None,
"volumeMax": float(speaker.volume_max),
"volumeMin": float(speaker.volume_min),
"distanceMax": float(speaker.distance_max),
"distanceReference": float(speaker.distance_reference),
"attenuation": float(speaker.attenuation),
"coneAngleOuter": float(speaker.cone_angle_outer),
"coneAngleInner": float(speaker.cone_angle_inner),
"coneVolumeOuter": float(speaker.cone_volume_outer),
"volume": float(speaker.volume),
"pitch": float(speaker.pitch),
}
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-speaker-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 = report()
descriptor, temporary = tempfile.mkstemp(prefix="m16-speaker-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=False)
after = report()
finally:
pathlib.Path(temporary).unlink(missing_ok=True)
if before != after:
raise RuntimeError(f"speaker save/reopen drift: {before} != {after}")
value = {"schemaVersion": 1, "task": "M16-GAP-00023", "operation": "SPEAKER_DATABLOCK_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "speaker": 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"speaker-desktop-ok id={after['id']} volume={after['volume']} saveReopen=exact")
if __name__ == "__main__":
main()