Fix Bug in mac-lookup

This commit is contained in:
TKE
2021-01-26 16:16:31 +01:00
parent 5d859a751d
commit 8b08b76f77

View File

@@ -15,10 +15,10 @@ def sym_time(val):
@functools.lru_cache() @functools.lru_cache()
def vendor(mac): def vendor(mac):
try: try:
from mac_vendor_lookup import MacLookup as mlu from mac_vendor_lookup import InvalidMacError, MacLookup as mlu
return mlu().lookup(mac) return mlu().lookup(mac.strip())
except InvalidMacError: except InvalidMacError:
return "not a MAC" return f"not a MAC {str(mac).strip()} of type {type(mac)}"
except ModuleNotFoundError: except ModuleNotFoundError:
return "module not available" return "module not available"
@@ -43,9 +43,10 @@ def dns_lookup(domain,record='A'):
def _ipinfo(ip): def _ipinfo(ip):
try: try:
import requests import requests
import json
r = requests.get(url='http://ipinfo.io/{}/json'.format(ip)) r = requests.get(url='http://ipinfo.io/{}/json'.format(ip))
return r.json() return r.json()
except simplejson.errors.JSONDecodeError as e: except json.JSONDecodeError as e:
return None return None
except ModuleNotFoundError: except ModuleNotFoundError:
return None return None