Files
workinf_Blender_Wasm/tools/web/check-action-assets-download-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

82 lines
2.9 KiB
Python

#!/usr/bin/env python3
import hashlib
import json
import pathlib
import sys
import tempfile
import bpy
IMAGE_NAME = "WebGapAssetsDownloadImage"
def image_state():
image = bpy.data.images.get(IMAGE_NAME)
if image is None:
raise RuntimeError("assets download fixture image is missing")
return {
"name": image.name,
"filepath": image.filepath,
"source": image.source,
"packed": image.packed_file is not None,
"size": [int(image.generated_width), int(image.generated_height)],
}
def main():
arguments = sys.argv[sys.argv.index("--") + 1 :]
if len(arguments) != 2:
raise SystemExit("usage: blender -b --python check-action-assets-download-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)
bpy.context.preferences.system.use_online_access = True
before = image_state()
poll = bool(bpy.ops.asset.assets_download.poll())
if poll:
raise RuntimeError("asset.assets_download unexpectedly polled true without selected asset")
try:
bpy.ops.asset.assets_download()
except RuntimeError as error:
if "No asset selected or active" not in str(error):
raise
operator_status = "CANCELLED"
else:
raise RuntimeError("asset.assets_download unexpectedly finished without selected asset")
after_cancel = image_state()
if after_cancel != before:
raise RuntimeError(f"asset.assets_download cancellation changed Main data: {before} != {after_cancel}")
with tempfile.NamedTemporaryFile(prefix="m16-assets-download-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 = image_state()
if after != before:
raise RuntimeError(f"asset.assets_download save/reopen drift: {before} != {after}")
report = {
"schemaVersion": 1,
"task": "M16-GAP-00265",
"operation": "ASSET_ASSETS_DOWNLOAD_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-assets-download-desktop-ok poll=false status=CANCELLED mainMutation=none saveReopen=exact")
if __name__ == "__main__":
try:
main()
except Exception as error:
print(f"asset-assets-download-desktop-failed: {error}")
raise SystemExit(1)