Skip to content

Commit

Permalink
fix: raise timeout to get OUI data in build (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Feb 24, 2024
1 parent 55e352d commit 19877f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
20 changes: 18 additions & 2 deletions build_oui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

from __future__ import annotations

import pathlib
from typing import Any

from generate_oui_data import generate
import requests # type: ignore


def build(setup_kwargs: dict[str, Any]) -> None:
"""Build the OUI data."""
generate()
resp = requests.get("https://standards-oui.ieee.org/oui.txt", timeout=20)
resp.raise_for_status()
oui_bytes = resp.content
oui_to_vendor = {}
for line in oui_bytes.splitlines():
if b"(base 16)" in line:
oui, _, vendor = line.partition(b"(base 16)")
oui_to_vendor[oui.strip()] = vendor.strip()
file = pathlib.Path(__file__)
target_file = file.parent.joinpath("src").joinpath("aiooui").joinpath("oui.data")
with open(target_file, "wb") as f:
f.write(b"\n".join(b"=".join((o, v)) for o, v in oui_to_vendor.items()))


if __name__ == "__main__":
build({})
25 changes: 0 additions & 25 deletions generate_oui_data.py

This file was deleted.

0 comments on commit 19877f5

Please sign in to comment.