def guard(): """Function to continually accept input and determine when to unlock door.""" # TODO: How can we verify that this is running? Should it periodically call home? LOGFORMAT = '%(asctime)-15s %(message)s' logging.basicConfig(filename='/var/log/latchburg.log', level=logging.DEBUG, format=LOGFORMAT) ver = Recognizer() interface = EntryAttemptInterface() with Latch() as latch: while True: try: attempt = interface.getAttempt() if attempt == None: break result = ver.check(attempt) if result != None: latch.unlock(INTERVAL) logging.info('Allowed access for user %s', result) else: logging.warning('Unauthorized attempt: %s', attempt) except Exception as inst: logging.error(inst)