Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
57
tools/web/check-wbv2-p0-003-desktop.py
Normal file
57
tools/web/check-wbv2-p0-003-desktop.py
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
CONTRACT_TEXT_NAME = "WBV2-P0-003-CapabilityContract"
|
||||
|
||||
|
||||
def read_contract():
|
||||
text = bpy.data.texts.get(CONTRACT_TEXT_NAME)
|
||||
if text is None:
|
||||
raise RuntimeError("CAPABILITY_CONTRACT_INVALID: contract text is missing")
|
||||
source = text.as_string()
|
||||
contract = json.loads(source)
|
||||
return source, contract
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-wbv2-p0-003-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)
|
||||
source, before = read_contract()
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="wbv2-p0-003-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_source, after = read_contract()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after or source != after_source:
|
||||
raise RuntimeError("CAPABILITY_CONTRACT_INVALID: desktop save/reopen drift")
|
||||
value = {
|
||||
"schemaVersion": 1,
|
||||
"task": "WBV2-P0-003",
|
||||
"operation": "CAPABILITY_ERROR_BUDGET_CONTRACT_DESKTOP",
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"contract": after,
|
||||
"sourceSha256": hashlib.sha256(after_source.encode("utf-8")).hexdigest(),
|
||||
"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"wbv2-p0-003-desktop-ok contract={after['contractId']} schemaHash={after['schemaHash']} saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user