def setup(): print "Gathering router MAC address" router_mac_address = Inet.get_router_mac_addy() # persist to current user directory as hidden file home = os.getenv("HOME") filename = ".trackr" filename = os.path.join(home, filename) # check if exists if not os.path.exists(filename): print "Initializing on first run..." print "Please answer some questions to help me setup. ;-)" f = open(filename, "w") question = "Where are you running this from:" choices = """ a) work? b) home? c) other? """ question += choices valid_responses = {"a": "work", "b": "home", "c": "other"} resp = raw_input(question.strip()).lower() location = {"work": "", "home": "", "other": ""} if resp in valid_responses.keys(): loc = valid_responses[resp] location[loc] = router_mac_address print "Saving MAC address %s for %s" % (router_mac_address, loc) else: print "Repeating the question...choose a, b, or c." pickle.dump(location, f) f.close() else: print "Load 'er up..."
from inet import Inet if __name__ == "__main__": # grab mac address mac = Inet.get_router_mac_addy() if(mac == None): print "Unable to retrieve route MAC address" #else # look for mac in our DB # found in DB?...log time # not found in DB?...ask user what this place is # periodically log MAC address
def blah(): from datetime import datetime print "%s (%s)" % (Inet.get_router_mac_addy(), datetime.today())