Files
workinf_Blender_Wasm/tools/web/check-action-catalog-new-desktop.py
mes123456 5c8cfd1a8c
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
Complete M16 asset operator parity chain
2026-08-23 18:10:00 -04:00

65 lines
2.8 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import pathlib
import sys
import tempfile
import bpy
def library_state():
libraries = list(bpy.data.libraries)
if len(libraries) != 1:
raise RuntimeError(f"expected one catalog-new library, found {len(libraries)}")
library = libraries[0]
return {"name": library.name, "filepath": library.filepath, "packed": library.packed_file is not None}
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-action-catalog-new-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 = library_state()
accepted_errors = ("context is incorrect", "No asset selected", "No asset library", "Catalog")
try:
poll = bool(bpy.ops.asset.catalog_new.poll())
except RuntimeError as error:
if not any(token in str(error) for token in accepted_errors):
raise
poll = False
if poll:
raise RuntimeError("asset.catalog_new unexpectedly polled true")
try:
bpy.ops.asset.catalog_new()
except RuntimeError as error:
if not any(token in str(error) for token in accepted_errors):
raise
operator_status = "CANCELLED"
else:
raise RuntimeError("asset.catalog_new unexpectedly finished")
after_cancel = library_state()
if after_cancel != before:
raise RuntimeError(f"catalog-new cancellation changed Main data: {before} != {after_cancel}")
with tempfile.NamedTemporaryFile(prefix="m16-catalog-new-reopen-", suffix=".blend", dir=fixture.parent) as temporary:
bpy.ops.wm.save_as_mainfile(filepath=temporary.name, check_existing=False, compress=True)
bpy.ops.wm.open_mainfile(filepath=temporary.name, load_ui=False)
after = library_state()
if after != before:
raise RuntimeError(f"catalog-new save/reopen drift: {before} != {after}")
report = {"schemaVersion": 1, "task": "M16-GAP-00270", "operation": "ASSET_CATALOG_NEW_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "before": before, "after": after, "poll": poll, "operatorStatus": operator_status, "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("asset-catalog-new-desktop-ok poll=false status=CANCELLED mainMutation=none saveReopen=exact")
if __name__ == "__main__":
try:
main()
except Exception as error:
print(f"asset-catalog-new-desktop-failed: {error}")
raise SystemExit(1)