def active_device(mac, ip='0.0.0.0', name='', time_stamp = datetime.datetime.now()): device_list = load_db() #time_stamp = datetime.datetime.now() mac_list = [] for d in device_list: mac_list.append(d._mac) if not mac in mac_list: #have not found this device previously if len(name) < 1: #FIXME: should be more automated - no input should really be required name = input('What is the name of this machine? ('+ip+', '+mac+') ') from device import Device unkn_d = Device(name, mac) unkn_d.add_ip(ip) unkn_d.add_ts(time_stamp) #print("Adding new DEVICE to DB") device_list.append(unkn_d) else: # already part of the db - only add time stamp #print("Updating existing DEVICE in DB") index = mac_list.index(mac) device_list[index].add_ip(ip) device_list[index].add_ts(time_stamp) save_db(device_list)