def get(mac_address, settings): api_client = ApiClient(settings["macaddress_io_api_key"]) try: response = api_client.get_raw_data(mac_address, 'json') return json.loads(response) except maclookup_exceptions.EmptyResponseException: raise LookupError('Empty response') except maclookup_exceptions.UnparsableResponseException: raise LookupError('Unparsable response') except maclookup_exceptions.ServerErrorException: raise LookupError('Internal server error') except maclookup_exceptions.UnknownOutputFormatException: raise LookupError('Unknown output') except maclookup_exceptions.AuthorizationRequiredException: raise LookupError('Authorization required') except maclookup_exceptions.AccessDeniedException: raise LookupError('Access denied') except maclookup_exceptions.InvalidMacOrOuiException: raise LookupError('Invalid MAC or OUI') except maclookup_exceptions.NotEnoughCreditsException: raise LookupError('Not enough credits') except Exception: raise LookupError('Unknown error')
from maclookup import ApiClient from io import open import logging import os api_key = os.environ['API_KEY'] log_file = os.environ['LOG_FILENAME'] output_file = os.environ['OUTPUT_FILENAME'] client = ApiClient(api_key) logging.basicConfig(filename=log_file, level=logging.WARNING) csv_data = client.get_raw_data('08EA4026E5DE', 'csv') f = open(output_file, 'w', encoding='utf-8') f.write(csv_data)
from maclookup import ApiClient import logging import os api_key = os.environ['API_KEY'] log_file = os.environ['LOG_FILENAME'] client = ApiClient(api_key) logging.basicConfig(filename=log_file, level=logging.WARNING) print(client.get_raw_data('08EA4026E5DE', 'csv')) print(client.get_vendor('08EA4026E5DE')) response = client.get('08EA4026E5DE') print(response.vendor_details.is_private) print(response.block_details.block_size)
import json import os mykey = os.environ.get('MY_KEY') if mykey == None: mykey = "at_EYedF482zqmiTdQyerFKVsBKlFNfc" #Get the movie name mac_addr = sys.argv[1] if len(mac_addr) == 0: print("Mac address missing") sys.exit() client = ApiClient(mykey) try: #vendor = client.get_vendor(mac_addr) #print ("Mac address: {} is for vendor: {}".format(mac_addr, vendor)) response = client.get_raw_data(mac_addr, 'json') json_text = json.loads(response) vendor = json_text['vendorDetails']['companyName'] if (len(vendor) > 0): print("Mac address: {} is for vendor: {}".format(mac_addr, vendor)) else: print("Mac address: {} does not match to any vendor".format(mac_addr)) except Exception as e: print("Error: get_vendor with erro: {}".format(str(e)))
from maclookup import ApiClient import logging client = ApiClient('at_gVL2VUlnXzRjD9mkj70Avd6bqgdkm') logging.basicConfig(filename='myapp.log', level=logging.WARNING) print(client.get_raw_data('00A043AAAAAA', 'json')) print(client.get_vendor('BBA043AAAAAA')) print(client.get('BBA043AAAAAA')) response = client.get('00A043AAAAAA') print(response.vendor_details.is_private) print(response.block_details.date_created)
from maclookup import ApiClient import json import sys, os api_key = os.environ['API_KEY'] client = ApiClient(api_key) try: macData = json.loads(client.get_raw_data(sys.argv[1], "json")) except: print "Not a valid MAC address" sys.exit(1) for key, val in macData.items(): print "-------", key, "-------" for skey, sval in val.items(): print skey, "=>", sval