Example #1
0
def doUnlock(reason):
	needToRestart = False
	try:
		import enroll
		from backend import backend

		import time

		backend.log('message', message='Unlock door: %s' % args.reason)
		if enroll.killDoorLock() != 1:
			needToRestart = True

		import rpi
		rpi.interfaceControl.unlockDoor()
	except KeyboardInterrupt:
		pass
	finally:
		if needToRestart:
			print("Locking door back")
			enroll.startDoorLock()
Example #2
0
def doUnlock(reason):
    needToRestart = False
    try:
        import enroll
        from backend import backend

        import time

        backend.log('message', message='Unlock door: %s' % args.reason)
        if enroll.killDoorLock() != 1:
            needToRestart = True

        import rpi
        rpi.interfaceControl.unlockDoor()
    except KeyboardInterrupt:
        pass
    finally:
        if needToRestart:
            print("Locking door back")
            enroll.startDoorLock()
Example #3
0
def checkCards():
#	log.debug("Starting NFC read")
	nfcID = interfaceControl.nfcGetUID()
#	log.debug("Finished NFC read")
	#interfaceControl.setPowerStatus(False)

	if nfcID != None:
		log.info("Scanned card ID: %s" % nfcID)
		user = backend.getUserByKeyID(nfcID)	
		if user != None:
			if user['status'] == 'active':
				log.info("ACCEPTED card ID: %s" % nfcID)
				log.info("Access granted to '%s %s'" % (user['firstName'], user['lastName']))
				backend.log('unlock', nfcID, user['userID'])
				log.info("Door 1: UNLOCKED")
				interfaceControl.unlockDoor()
				proc = subprocess.Popen(['/home/pi/code/makeictelectronicdoor/vista/disarm.sh'], stdout=subprocess.PIPE)
				proc.communicate()
				log.info("Door 1: LOCKED")
			else:
				log.warning("DENIED card  ID: %s" % nfcID)
				log.warning("Reason: '%s %s' is not active" % (user['firstName'], user['lastName']))
				backend.log('deny', nfcID, user['userID'])
				interfaceControl.showBadCardRead()
		else:
			log.warning("DENIED card  ID: %s" % nfcID)
			log.warning("Reason: card not registered")
			backend.log('deny', nfcID)
			interfaceControl.showBadCardRead()
Example #4
0
def checkCards():
    #	log.debug("Starting NFC read")
    nfcID = interfaceControl.nfcGetUID()
    #	log.debug("Finished NFC read")
    #interfaceControl.setPowerStatus(False)

    if nfcID != None:
        log.info("Scanned card ID: %s" % nfcID)
        user = backend.getUserByKeyID(nfcID)
        if user != None:
            if user['status'] == 'active':
                log.info("ACCEPTED card ID: %s" % nfcID)
                log.info("Access granted to '%s %s'" %
                         (user['firstName'], user['lastName']))
                backend.log('unlock', nfcID, user['userID'])
                log.info("Door 1: UNLOCKED")
                interfaceControl.unlockDoor()
                proc = subprocess.Popen(
                    ['/home/pi/code/makeictelectronicdoor/vista/disarm.sh'],
                    stdout=subprocess.PIPE)
                proc.communicate()
                log.info("Door 1: LOCKED")
            else:
                log.warning("DENIED card  ID: %s" % nfcID)
                log.warning("Reason: '%s %s' is not active" %
                            (user['firstName'], user['lastName']))
                backend.log('deny', nfcID, user['userID'])
                interfaceControl.showBadCardRead()
        else:
            log.warning("DENIED card  ID: %s" % nfcID)
            log.warning("Reason: card not registered")
            backend.log('deny', nfcID)
            interfaceControl.showBadCardRead()