Files
workinf_Blender_Wasm/tools/web/check-action-catalog-undo-push-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

28 lines
2.2 KiB
Python

#!/usr/bin/env python3
import hashlib,json,pathlib,sys,tempfile,bpy
def state():
if len(bpy.data.libraries)!=1: raise RuntimeError("catalog-undo-push library missing")
lib=bpy.data.libraries[0]; return {"name":lib.name,"filepath":lib.filepath,"packed":lib.packed_file is not None}
def main():
args=sys.argv[sys.argv.index("--")+1:]
if len(args)!=2: raise SystemExit("usage")
fixture,output=(pathlib.Path(v).resolve() for v in args); bpy.ops.wm.open_mainfile(filepath=str(fixture),load_ui=False); before=state(); accepted=("context is incorrect","No asset selected","No asset library","Catalog")
try: poll=bool(bpy.ops.asset.catalog_undo_push.poll())
except RuntimeError as e:
if not any(x in str(e) for x in accepted): raise
poll=False
if poll: raise RuntimeError("catalog_undo_push poll unexpectedly true")
try: bpy.ops.asset.catalog_undo_push()
except RuntimeError as e:
if not any(x in str(e) for x in accepted): raise
status="CANCELLED"
else: raise RuntimeError("catalog_undo_push unexpectedly finished")
if state()!=before: raise RuntimeError("catalog_undo_push mutated Main")
with tempfile.NamedTemporaryFile(prefix="m16-catalog-undo-push-reopen-",suffix=".blend",dir=fixture.parent) as t:
bpy.ops.wm.save_as_mainfile(filepath=t.name,check_existing=False,compress=True); bpy.ops.wm.open_mainfile(filepath=t.name,load_ui=False); after=state()
if after!=before: raise RuntimeError("catalog_undo_push save/reopen drift")
report={"schemaVersion":1,"task":"M16-GAP-00273","operation":"ASSET_CATALOG_UNDO_PUSH_DESKTOP","fixture":str(fixture),"fixtureSha256":hashlib.sha256(fixture.read_bytes()).hexdigest(),"before":before,"after":after,"poll":poll,"operatorStatus":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"); print("asset-catalog-undo-push-desktop-ok poll=false status=CANCELLED mainMutation=none saveReopen=exact")
if __name__=="__main__":
try: main()
except Exception as e: print(f"asset-catalog-undo-push-desktop-failed: {e}"); raise SystemExit(1)