From 777e92c96a85f499ec272c0d130c631e5bf6362a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 10 Dec 2018 15:10:23 +0100 Subject: oui.conf: update from upstream Signed-off-by: Tobias Klauser --- contrib/oui-update.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'contrib') diff --git a/contrib/oui-update.py b/contrib/oui-update.py index 07add9f..3e4ddde 100755 --- a/contrib/oui-update.py +++ b/contrib/oui-update.py @@ -14,14 +14,14 @@ import sys import re import getopt try: - from urllib2 import urlopen # Python 2.x -except ImportError: - from urllib.request import urlopen # Python 3.x + from urllib.request import urlopen +except ImportError as e: + raise Exception("Please run this script with Python 3") DEFAULT_OUPUT_FILE = "oui.conf" DEFAULT_OUI_URL = "http://standards.ieee.org/develop/regauth/oui/oui.txt" -OUI_PATTERN = re.compile(b"^\s*([a-fA-F0-9]{2})-([a-fA-F0-9]{2})-([a-fA-F0-9]{2})\s+\(hex\)\s+(.*)$") +OUI_PATTERN = re.compile("^\s*([a-fA-F0-9]{6})\s+\(base 16\)\s+(.*)$") def usage(): print("""usage: {0} [OPTION...] @@ -63,13 +63,16 @@ def main(): print("Updating OUI information in {} from {}... ".format(output_file, oui_url)) fh_url = urlopen(oui_url) + encoding = fh_url.headers.get_content_charset() + if not encoding: + encoding = "utf-8" ouis = [] for line in fh_url: - m = OUI_PATTERN.match(line) + m = OUI_PATTERN.match(line.decode(encoding)) if m: - oui = "0x{}{}{}".format(m.group(1), m.group(2), m.group(3)) - vendor = m.group(4).rstrip() + oui = "0x{}".format(m.group(1)) + vendor = m.group(2).rstrip() ouis.append((oui, vendor)) fh_file = open(output_file, 'w') -- cgit v1.2.3-54-g00ecf