### MacLookup.get_last_updated() - Get Last Updated Timestamp Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Returns a datetime object indicating when the cached vendor list was last modified. ```APIDOC ## MacLookup.get_last_updated() ### Description Returns a datetime object indicating when the cached vendor list was last modified. Useful for determining if the vendor list needs to be refreshed. ### Method `MacLookup.get_last_updated()` ### Parameters None ### Request Example ```python from mac_vendor_lookup import MacLookup mac = MacLookup() # Check when the vendor list was last updated last_updated = mac.get_last_updated() if last_updated: print(f"Vendor list last updated: {last_updated}") else: print("No vendor list found, will be downloaded on first lookup") ``` ### Response #### Success Response (200) - **last_updated** (datetime) - A datetime object representing the last modification time of the cached vendor list, or None if no list is found. #### Response Example ```json { "last_updated": "2024-01-15 10:30:45.123456" } ``` ``` -------------------------------- ### Get Last Updated Timestamp Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Retrieves the datetime object indicating when the cached vendor list was last modified. Useful for checking if a refresh is needed. ```python from mac_vendor_lookup import MacLookup mac = MacLookup() # Check when the vendor list was last updated last_updated = mac.get_last_updated() if last_updated: print(f"Vendor list last updated: {last_updated}") # Output: Vendor list last updated: 2024-01-15 10:30:45.123456 else: print("No vendor list found, will be downloaded on first lookup") ``` -------------------------------- ### Command Line Interface Usage Source: https://github.com/bauerj/mac_vendor_lookup/blob/master/README.md The library can be used from the command line to look up vendors. It accepts MAC addresses with hyphens or colons as separators. ```bash $ mac_vendor_lookup 50-D3-7F-00-01-00 Yu Fly Mikly Way Science and Technology Co., Ltd. $ python3 -m mac_vendor_lookup 00:26:12:12:FE Space Exploration Technologies ``` -------------------------------- ### Mac Vendor Lookup Command Line Usage Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Provides command-line tools for quick MAC address lookups without writing Python code. Supports various MAC address formats and includes error handling for unregistered prefixes and invalid MAC addresses. ```bash # Direct command usage $ mac_vendor_lookup 50-D3-7F-00-01-00 Yu Fly Mikly Way Science and Technology Co., Ltd. ``` ```bash # Using Python module syntax $ python3 -m mac_vendor_lookup 00:26:12:12:FE Space Exploration Technologies ``` ```bash # Colon-separated format $ mac_vendor_lookup 00:80:41:12:FE VEB KOMBINAT ROBOTRON ``` ```bash # Error handling for unregistered prefixes $ mac_vendor_lookup 00:00:00:00:00:00 Prefix is not registered ``` ```bash # Error handling for invalid MAC $ mac_vendor_lookup not-a-mac Invalid MAC address: not-a-mac contains unexpected character ``` -------------------------------- ### Basic MAC Address Lookup Source: https://github.com/bauerj/mac_vendor_lookup/blob/master/README.md Instantiate MacLookup and call the lookup method with a MAC address string. ```python from mac_vendor_lookup import MacLookup print(MacLookup().lookup("00:80:41:12:FE")) ``` -------------------------------- ### Update Vendor List from IEEE Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Downloads the latest OUI vendor list from IEEE and caches it locally. This operation may take several seconds and ensures up-to-date vendor information. ```python from mac_vendor_lookup import MacLookup mac = MacLookup() # Update the vendor list from IEEE # This downloads from https://standards-oui.ieee.org/oui/oui.txt mac.update_vendors() print("Vendor list updated successfully") # Now lookups will use the fresh data vendor = mac.lookup("00:26:12:12:FE:00") print(vendor) # Output: Space Exploration Technologies ``` -------------------------------- ### Update Vendor List (Sync) Source: https://github.com/bauerj/mac_vendor_lookup/blob/master/README.md Use MacLookup.update_vendors() to download the latest vendor list from IEEE. This operation can take a few seconds. ```python from mac_vendor_lookup import MacLookup mac = MacLookup() mac.update_vendors() # <- This can take a few seconds for the download def find_mac(mac_address): print(mac.lookup(mac_address)) ``` -------------------------------- ### Async Vendor List Update and Lookup Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Asynchronously downloads the latest vendor list from IEEE using aiohttp and aiofiles. This is useful for modern async applications to avoid blocking the event loop. ```python import asyncio from mac_vendor_lookup import AsyncMacLookup async def main(): mac = AsyncMacLookup() # Async update of vendor list await mac.update_vendors() print("Vendor list updated") # Use fresh data for lookups vendor = await mac.lookup("00:26:12:12:12:FE:00") print(f"Vendor: {vendor}") # Output: Vendor: Space Exploration Technologies asyncio.run(main()) ``` -------------------------------- ### Asynchronous MAC Address Lookup Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Provides an asynchronous interface for MAC address lookups using Python's asyncio. Supports single lookups and concurrent lookups using asyncio.gather. ```python import asyncio from mac_vendor_lookup import AsyncMacLookup, VendorNotFoundError async def main(): mac = AsyncMacLookup() # Single async lookup vendor = await mac.lookup("98:ED:5C:FF:EE:01") print(vendor) # Output: Tesla Motors, Inc # Multiple concurrent lookups mac_addresses = [ "00:80:41:12:FE:00", "00:26:12:12:FE:00", "50-D3-7F-00-01-00" ] results = await asyncio.gather( *[mac.lookup(addr) for addr in mac_addresses], return_exceptions=True ) for addr, result in zip(mac_addresses, results): if isinstance(result, Exception): print(f"{addr}: Error - {result}") else: print(f"{addr}: {result}") # Output: # 00:80:41:12:FE:00: VEB KOMBINAT ROBOTRON # 00:26:12:12:FE:00: Space Exploration Technologies # 50-D3-7F-00-01-00: Yu Fly Mikly Way Science and Technology Co., Ltd. asyncio.run(main()) ``` -------------------------------- ### Custom Cache Path Configuration Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Allows setting a custom path for storing and loading the vendor list by overriding the BaseMacLookup.cache_path class variable before instantiating MacLookup. ```python from mac_vendor_lookup import MacLookup, BaseMacLookup # Set custom cache path before creating instance BaseMacLookup.cache_path = "/var/cache/mac-vendors.txt" mac = MacLookup() mac.update_vendors() # Downloads to custom location # Subsequent lookups use the custom cache vendor = mac.lookup("50-D3-7F-00-01-00") print(vendor) # Output: Yu Fly Mikly Way Science and Technology Co., Ltd. ``` -------------------------------- ### MacLookup.update_vendors() - Update Vendor List Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Downloads the latest OUI vendor list directly from IEEE and caches it locally. ```APIDOC ## MacLookup.update_vendors() ### Description Downloads the latest OUI vendor list directly from IEEE and caches it locally. This ensures you have the most up-to-date vendor information, as new manufacturers are regularly added to the IEEE registry. The download may take several seconds depending on network conditions. ### Method `MacLookup.update_vendors()` ### Parameters None ### Request Example ```python from mac_vendor_lookup import MacLookup mac = MacLookup() # Update the vendor list from IEEE mac.update_vendors() print("Vendor list updated successfully") ``` ### Response #### Success Response (200) Indicates the vendor list was updated successfully. No specific data is returned, but the local cache is refreshed. #### Response Example ``` Vendor list updated successfully ``` ``` -------------------------------- ### AsyncMacLookup.lookup() - Asynchronous MAC Address Lookup Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Asynchronous version of the MAC address lookup, designed for use with Python's asyncio. ```APIDOC ## AsyncMacLookup.lookup() ### Description Asynchronous version of the MAC address lookup, designed for use with Python's asyncio. Ideal for applications that need to perform multiple lookups concurrently or integrate with async web frameworks. ### Method `await AsyncMacLookup.lookup(mac_address)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import asyncio from mac_vendor_lookup import AsyncMacLookup, VendorNotFoundError async def main(): mac = AsyncMacLookup() # Single async lookup vendor = await mac.lookup("98:ED:5C:FF:EE:01") print(vendor) # Multiple concurrent lookups mac_addresses = [ "00:80:41:12:FE:00", "00:26:12:12:FE:00", "50-D3-7F-00-01-00" ] results = await asyncio.gather( *[mac.lookup(addr) for addr in mac_addresses], return_exceptions=True ) for addr, result in zip(mac_addresses, results): if isinstance(result, Exception): print(f"{addr}: Error - {result}") else: print(f"{addr}: {result}") asyncio.run(main()) ``` ### Response #### Success Response (200) - **vendor** (string) - The name of the vendor/manufacturer. #### Response Example ```json { "vendor": "Tesla Motors, Inc" } ``` ``` -------------------------------- ### Asynchronous MAC Address Lookup Source: https://github.com/bauerj/mac_vendor_lookup/blob/master/README.md Utilize the AsyncMacLookup class for asynchronous operations. The lookup method must be awaited within an async function. ```python from mac_vendor_lookup import AsyncMacLookup async def main(): mac = AsyncMacLookup() print(await mac.lookup("98:ED:5C:FF:EE:01")) ``` -------------------------------- ### Set Custom Cache Path Source: https://github.com/bauerj/mac_vendor_lookup/blob/master/README.md Override BaseMacLookup.cache_path to specify a custom location for storing the vendor list. After setting the path, call update_vendors() to download and store the list in the new location. ```python from mac_vendor_lookup import MacLookup, BaseMacLookup BaseMacLookup.cache_path = "/relative/or/absolute/path/to/the/prefered/storage/location" mac = MacLookup() mac.update_vendors() # <- This can take a few seconds for the download and it will be stored in the new path def find_mac(mac_address): print(mac.lookup(mac_address)) ``` -------------------------------- ### BaseMacLookup.cache_path - Custom Cache Path Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Class variable to control the storage location of the vendor list cache. ```APIDOC ## BaseMacLookup.cache_path ### Description Class variable that controls where the vendor list is stored and loaded from. Override this before creating a MacLookup instance to use a custom storage location. ### Method `BaseMacLookup.cache_path = "/path/to/your/cache/file.txt"` ### Parameters - **cache_path** (string) - Required - The absolute path to the desired cache file. ### Request Example ```python from mac_vendor_lookup import MacLookup, BaseMacLookup # Set custom cache path before creating instance BaseMacLookup.cache_path = "/var/cache/mac-vendors.txt" mac = MacLookup() mac.update_vendors() # Downloads to custom location # Subsequent lookups use the custom cache vendor = mac.lookup("50-D3-7F-00-01-00") print(vendor) ``` ### Response This is a configuration setting, not an endpoint with a direct response. Successful configuration allows subsequent operations to use the specified cache path. ``` -------------------------------- ### MacLookup.lookup() - Synchronous MAC Address Lookup Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Performs a synchronous lookup of a MAC address to find the vendor/manufacturer name. Supports various MAC address formats. ```APIDOC ## MacLookup.lookup() ### Description Performs a synchronous lookup of a MAC address to find the vendor/manufacturer name. Accepts MAC addresses in multiple formats including colon-separated (00:80:41:12:FE:00), dash-separated (00-80-41-12-FE-00), or plain hexadecimal (008041). The first 6 hex characters (OUI prefix) are used for the lookup. ### Method `MacLookup.lookup(mac_address)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from mac_vendor_lookup import MacLookup, VendorNotFoundError, InvalidMacError mac = MacLookup() # Basic lookup with colon-separated format vendor = mac.lookup("00:80:41:12:FE:00") print(vendor) # Dash-separated format also works vendor = mac.lookup("98-ED-5C-FF-EE-01") print(vendor) # Plain hex format (minimum 6 characters for OUI) vendor = mac.lookup("008041") print(vendor) # Error handling for unknown vendors try: vendor = mac.lookup("00:00:00:00:00:00") except VendorNotFoundError as e: print(f"Vendor not found: {e}") # Error handling for invalid MAC addresses try: vendor = mac.lookup("invalid-mac") except InvalidMacError as e: print(f"Invalid MAC: {e}") ``` ### Response #### Success Response (200) - **vendor** (string) - The name of the vendor/manufacturer. #### Response Example ```json { "vendor": "VEB KOMBINAT ROBOTRON" } ``` ``` -------------------------------- ### Synchronous MAC Address Lookup Source: https://context7.com/bauerj/mac_vendor_lookup/llms.txt Performs a synchronous lookup for a vendor using a MAC address. Supports colon-separated, dash-separated, and plain hex formats. Handles VendorNotFoundError and InvalidMacError. ```python from mac_vendor_lookup import MacLookup, VendorNotFoundError, InvalidMacError mac = MacLookup() # Basic lookup with colon-separated format vendor = mac.lookup("00:80:41:12:FE:00") print(vendor) # Output: VEB KOMBINAT ROBOTRON # Dash-separated format also works vendor = mac.lookup("98-ED-5C-FF-EE-01") print(vendor) # Output: Tesla Motors, Inc # Plain hex format (minimum 6 characters for OUI) vendor = mac.lookup("008041") print(vendor) # Output: VEB KOMBINAT ROBOTRON # Error handling for unknown vendors try: vendor = mac.lookup("00:00:00:00:00:00") except VendorNotFoundError as e: print(f"Vendor not found: {e}") # Output: The vendor for MAC b'000000' could not be found... # Error handling for invalid MAC addresses try: vendor = mac.lookup("invalid-mac") except InvalidMacError as e: print(f"Invalid MAC: {e}") # Output: invalid-mac contains unexpected character ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.