Example #1
0
File: app.py Project: iamsk/doorbot
def door():
    email = request.forms.get('email')
    password = request.forms.get('password')
    if borg.validate(email, password):
        logger.info('%s logined in.' % email)
        open()
        return "Door opened!"
    else:
        return "Username/Password invalid!"
Example #2
0
def on_tag_connect(tag):
    id_str = reader.get_id(tag)
    print('ID: ' + id_str)
    print('Product: ' + tag.product)

    if tag.product not in {'NXP NTAG203', 'NXP NTAG213'}:
        print('Invalid tag type')
        #reader.beep(clf, 3)
        time.sleep(5)
        return True

    if db.check_exit_tags(id_str) is True:
        print('Exit tag scanned, closing...')
        clf.close()
        return True

    if db.check_whitelist(id_str) is True:
        print('Tag in whitelist authenticated')
        #reader.beep(clf, 2)
        door.open()
        return True

    if db.check_blacklist(id_str) is True:
        print('Blacklisted card tried to open')
        #reader.beep(clf, 5)
        return True

    login_str = login.retrieve(id_str)
    if login_str == 'UNKNOWN':
        print('Unknown card scanned')
        #reader.beep(clf, 3)
        return True
    print('Authentified ' + login_str)

    try:
        reader.write_time_record(tag)
    except nfc.tag.tt2.Type2TagCommandError:
        print('Error when writing tag')
        #reader.beep(clf, 1)
        time.sleep(1)
    #reader.beep(clf, 1)
    door.open()
    return True
Example #3
0
def draw_result(frame, face_locations, face_names):
    font = cv2.FONT_HERSHEY_DUPLEX

    for (top, right, bottom, left), name in zip(face_locations, face_names):
        rectangleColor = (255, 255, 255)
        textColor = (0, 0, 0)
        if name != "Unknown":
            door.open(name)
            rectangleColor = (192, 223, 133)
            textColor = (255, 255, 255)
        top *= 4
        right *= 4
        bottom *= 4
        left *= 4
        cv2.rectangle(frame, (left, top), (right, bottom), rectangleColor, 2)
        cv2.rectangle(frame, (left, bottom - 35), (right, bottom),
                      rectangleColor, cv2.FILLED)
        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, textColor,
                    1)
    draw_state(frame)
Example #4
0
import evdev
import database
import door
import time

#
# Service to read the card reader (RFID)
# and open (or not) the door based on what's in the DB
#
device = evdev.InputDevice('/dev/input/event0')

cardcode = ''
for event in device.read_loop():
    if event.type == evdev.ecodes.EV_KEY:
        keyevent = evdev.categorize(event)
        if keyevent.keystate == 1:
            code = int(keyevent.scancode)
            if code == 28:
                success = False
                if database.containsCard(cardcode):
                    door.open(cardcode)
                    time.sleep(3)
                    door.close()
                    success = True
                database.log_card(cardcode, success)
                cardcode = ''
            elif code == 11:
                cardcode = cardcode + '0'
            else:
                cardcode = cardcode + str(code - 1)
Example #5
0
#!/usr/bin/python3

import door

door.open("Startup")
Example #6
0
import evdev
import database
import door
import time

#
# Service to read the card reader (RFID)
# and open (or not) the door based on what's in the DB
#
device = evdev.InputDevice('/dev/input/event0')

cardcode = ''
for event in device.read_loop():
    if event.type == evdev.ecodes.EV_KEY:
        keyevent = evdev.categorize(event)
        if keyevent.keystate == 1:
            code = int(keyevent.scancode)
            if code == 28:
                success = False
                if database.containsCard(cardcode):
                   door.open(cardcode)
                   time.sleep(3)
                   door.close()
                   success = True
                database.log_card(cardcode, success)
                cardcode = ''
            elif code == 11:
                cardcode = cardcode + '0'
            else:
                cardcode = cardcode + str(code - 1)
Example #7
0
import door
import time
import pifacedigitalio

pfd = pifacedigitalio.PiFaceDigital()

while True:
    if pfd.input_pins[4].value == 1:
        door.open("Button")
        time.sleep(3)
        door.close()

    # Just to be nice with the proc
    time.sleep(0.1)
Example #8
0
#!/usr/bin/env python

import sys
import door
#import keys

if (sys.argv[1]=='check'):
    state=door.check()
    print state

if (sys.argv[1]=='addkey'):
    keys.adddkey(sys.argv[2],sys.argv[3],sys.argv[4])
    print "1"
    
if (sys.argv[1]=='toggle'):
    door.toggle(sys.argv[2],sys.argv[3])
    print "1"

    
if (sys.argv[1]=='open'):
    door.open(sys.argv[2])
    print "1"
    
if (sys.argv[1]=='close'):
    door.close(sys.argv[2])
    print "1"