44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Fail closed on the frozen WeatherV2 QBIN manifest and its bundled raw copies."""
|
|
|
|
import hashlib
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPOSITORY = Path(__file__).resolve().parents[4]
|
|
SOURCE = Path("/root/sourceserver/weatherV2/_artifacts/MapLibre_QBIN_V2_单元测试数据_v1")
|
|
BUNDLED = REPOSITORY / "integration/react-native/MapLibreParticleRNTestHost/assets/qbin-golden"
|
|
DESTINATION_LAYER = {"wind": "wind", "wave": "wave", "tide": "current", "rain": "rain"}
|
|
|
|
|
|
def digest(path: Path) -> str:
|
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
|
|
|
|
def main() -> int:
|
|
manifest = json.loads((SOURCE / "清单.json").read_text(encoding="utf-8"))
|
|
checked = 0
|
|
for source_layer, destination_layer in DESTINATION_LAYER.items():
|
|
frames = manifest["layers"][source_layer]["frames"]
|
|
if len(frames) != 2:
|
|
raise RuntimeError(f"{source_layer}: expected exactly two frozen frames")
|
|
for index, frame in enumerate(frames):
|
|
label = "T0" if index == 0 else "T1"
|
|
source = SOURCE / source_layer / frame["file"]
|
|
bundled = BUNDLED / destination_layer / f"{label}.qbin"
|
|
expected_bytes = frame["raw_bytes"]
|
|
expected_sha256 = frame["sha256"]
|
|
for name, path in (("source", source), ("bundled", bundled)):
|
|
if not path.is_file() or path.stat().st_size != expected_bytes or digest(path) != expected_sha256:
|
|
raise RuntimeError(f"{source_layer}/{frame['target_time']} {name} does not match frozen raw QBIN manifest")
|
|
checked += 1
|
|
if checked != 8:
|
|
raise RuntimeError(f"expected eight frames, checked {checked}")
|
|
print("QBIN_FIXTURE_SOURCE_AND_COPY=PASS (8 raw files)")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|