Code Monkey home page Code Monkey logo

ouilookup's Introduction

ouilookup

PyPi Python Versions build tests License

A CLI tool and Python module for looking up hardware MAC addresses from the published OUI source list at ieee.org.

Project

Install

via PyPi

pip3 install ouilookup

Versions

Legacy versions based on year-date (eg v2018.2) have been hard-deprecated in favour of a backward incompatible standard versioning scheme (eg v0.2.0).

CLI usage

usage: ouilookup [-h] [-q [<hwaddr> ...] | -s | -u | -ul <filename>] [-d] [-df <data-file>]

ouilookup v0.3.0

options:
  -h, --help            show this help message and exit
  -q [<hwaddr> ...], --query [<hwaddr> ...]
                        Query to locate matching MAC hardware address(es) from 
                        the oui ouilookup.json data file. Addresses may be 
                        expressed in formats with or without ':' or '-' 
                        separators. Use a space or comma between addresses to 
                        query for more than one item in a single query.
  -s, --status          Return status metadata about the ouilookup.json data 
                        file.
  -u, --update          Download the latest from 
                        https://standards-oui.ieee.org/oui/oui.txt then parse 
                        and save as a ouilookup.json data file.
  -ul <filename>, --update-local <filename>
                        Supply a local oui.txt then parse and save as a 
                        ouilookup.json data file.

  -d, --debug           Enable debug logging
  -df <data-file>, --data-file <data-file>
                        Use a data file that is not in the default data file 
                        search paths: /home/<user>/.local/ouilookup, 
                        <package-path>/ouilookup/data, /var/lib/ouilookup

A CLI tool for interfacing with the OuiLookup module that provides CLI access 
the query(), update() and status() functions. Outputs at the CLI are JSON 
formatted allowing for easy chaining with other toolchains. The update() 
function updates directly from "standards-oui.ieee.org".

Python3 Module usage

>>> from OuiLookup import OuiLookup

>>> OuiLookup().query('00:00:aa:00:00:00')
[{'0000AA000000': 'XEROX CORPORATION'}]

>>> OuiLookup().query(['00:00:01:00:00:00','00-00-10-00-00-00','000011000000'])
[{'000001000000': 'XEROX CORPORATION'}, {'000010000000': 'SYTEK INC.'}, {'000011000000': 'NORMEREL SYSTEMES'}]

>>> OuiLookup().update()
{'timestamp': '2023-05-13T14:11:17+00:00', 'source_url': 'https://standards-oui.ieee.org/oui/oui.txt', 'source_data_file': '/tmp/ouilookup-qm5aq0dk/oui.txt', 'source_bytes': '5468392', 'source_md5': '55a434f90da0c24c1a4fcfefe5b2b64b', 'source_sha1': 'dd5e8849ab8c65b2fb12c4b5aef290afee6bbfcd', 'source_sha256': 'af7e4bb1394109f4faad814074d3a6d5b792078074549a5d554c0904612c0bfc', 'vendor_count': '33808', 'data_file': '~/.local/ouilookup/ouilookup.json'}
>>> OuiLookup().status()
{'timestamp': '2023-05-13T14:11:17+00:00', 'source_url': 'https://standards-oui.ieee.org/oui/oui.txt', 'source_data_file': '/tmp/ouilookup-qm5aq0dk/oui.txt', 'source_bytes': '5468392', 'source_md5': '55a434f90da0c24c1a4fcfefe5b2b64b', 'source_sha1': 'dd5e8849ab8c65b2fb12c4b5aef290afee6bbfcd', 'source_sha256': 'af7e4bb1394109f4faad814074d3a6d5b792078074549a5d554c0904612c0bfc', 'vendor_count': '33808', 'data_file': '~/.local/ouilookup/ouilookup.json'}

Authors

License

BSD-2-Clause - see LICENSE file for full details.

NB: License change from Apache-2.0 to BSD-2-Clause in February 2020 at version 0.2.0

ouilookup's People

Contributors

laurentfough avatar ndejong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ouilookup's Issues

Import statement changing between versions and python 3.6 incompatibility

The module name might have changed from 0.2.4 to 0.3.1 so the import statement went from:
from OuiLookup import OuiLookup to from ouilookup import OuiLookup

The 0.3.1 version also throws the following error with Python 3.6:

  File "C:\Python36\lib\site-packages\ouilookup\__init__.py", line 23, in <module>
    from .main import OuiLookup  # noqa: E402
  File "<fstring>", line 1
    (expression=)
               ^
SyntaxError: invalid syntax

Possibly a newer string formatting method that's not compatible with 3.6 according to https://stackoverflow.com/questions/49582183/pythonl-invalid-syntax-file-fstring-line-1

OuiLookupException: Unable to download from data source

Script:

from ouilookup import OuiLookup

OuiLookup().query('00:00:aa:00:00:00')
OuiLookup().query(['00:00:01:00:00:00','00-00-10-00-00-00','000011000000'])
OuiLookup().update()
OuiLookup().status()

Output:

Traceback (most recent call last):
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 1344, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1336, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1382, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1331, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1091, in _send_output
    self.send(msg)
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1035, in send
    self.connect()
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\http\client.py", line 1477, in connect
    self.sock = self._context.wrap_socket(self.sock,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 455, in wrap_socket
    return self.sslsocket_class._create(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 1042, in _create
    self.do_handshake()
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\site-packages\ouilookup\main.py", line 83, in update
    urllib.request.urlretrieve(__data_source_url__, source_data_file)
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 240, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
                            ^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 515, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 532, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 1392, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 1347, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\BUZZARD\Desktop\test.py", line 7, in <module>
    OuiLookup().update()
  File "C:\Users\BUZZARD\AppData\Local\Programs\Python\Python312\Lib\site-packages\ouilookup\main.py", line 85, in update
    raise OuiLookupException(f"Unable to download from data source {str(e)}")
ouilookup.exceptions.OuiLookupException: Unable to download from data source <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)>

C:\Users\BUZZARD\Desktop>

Using a fresh new Windows 10 VM.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.