Example #1
0
def get_task(task_id):
    airodump_csv_to_json.convert()
    hexstr = task_id
    hex = ':'.join([hexstr[i:i+2] for i in range(0, len(hexstr), 2)]) #Turns a string of MAC address to MAC hex format
    with open('dump.json') as data_file:
	tasks = json.load(data_file) #Refreshes the dump.json file
    task = [task for task in tasks if task['mac'] == hex] #Selects JSON with 'mac' data
    if len(task) == 0:
	abort(404)
    return jsonify({'Face': task[0]})
Example #2
0
def get_MAC(maxima_id):
    airodump_csv_to_json.convert()
    with open('dump.json') as data_file:
	macfile = json.load(data_file) #Refreshes the dump.json file
    count = 0
    List = []
    while True:
	macpower = int(macfile[count]['power']) #Changes str format to int format
	count += 1
	if macpower >= -80 and macpower < -1:
	    List.append(macpower)
	else:
	    pass
	if count == len(macfile):
	    break
    List = map(int, List)
    #List = filter(lambda a: a != '-1', List)
    highestpower = max(List)
    maximum = int(maxima_id)
    orderedhighestpower = sorted(set(List))[-maximum] #Allows us to choose order eg. 1st, 2nd etc within List
    mactask = [mactask for mactask in macfile if mactask['power'] == str(orderedhighestpower)] #Selects JSON with 'mac' data
    if len(mactask) == 0:
	abort(404)
    return jsonify({'Face': mactask[0]})