"""Download the offline reference datasets at image build time.""" import pathlib import urllib.request SOURCES = { "manuf": "https://www.wireshark.org/download/automated/data/manuf", "iana-ports.csv": "https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.csv", } target = pathlib.Path("owuitools/data") target.mkdir(parents=True, exist_ok=True) for name, url in SOURCES.items(): path = target / name try: request = urllib.request.Request(url, headers={"User-Agent": "owuitools-build/1.0"}) with urllib.request.urlopen(request, timeout=60) as response: path.write_bytes(response.read()) print(f" fetched {name}: {path.stat().st_size:,} bytes") except Exception as exc: print(f" WARNING: could not fetch {name} ({exc}); " "network_reference will report it unavailable") path.touch()