Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: raise timeout to get OUI data in build #3

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.