示例#1
0
def scheduledTask():
    access_token = os.getenv('access_token')
    updateData(access_token)
def login():
    """
        Here we read a rfid card and try to log the user in.
        firstly we get the rfidCards from the database.
    """
    dbData = gD.getData('loggedIn, rfidNumber, customerID', 'loginInfo')

    global cardA, keypad, backData, scanPass
    while True:
        breakOut = reader(False)
        cardData = backData
        cardData = str(cardData)
        backData = ""
        if keypad.getKey() == "*" or breakOut == True:
            sleep(1)
            if scanPass != "":
                close(scanPass)
                scanPass = ""
            #turn off all led colors
            GPIO.output(ledRed, False)
            GPIO.output(ledGreen, False)
            GPIO.output(ledBlue, False)
            break

        else:
            rowCounter = 1
            for row in dbData:
                    if cardData == row[1] and row[0] == 1:
                        # GPIO.output(ledRed, False)
                        # GPIO.output(ledGreen, True)
                        servoThread = threading.Thread(target=turnServo)
                        servoThread.start()
                        for i in range(3):
                            GPIO.output(ledGreen, False)
                            sleep(0.3)
                            GPIO.output(ledGreen, True)
                            sleep(0.3)
                        # GPIO.output(ledGreen, False)
                        # GPIO.output(ledRed, True)
                        updateInjection = ('customerID = ' + str(row[2]))
                        gD.updateData('loginInfo', 'loggedIn = false', updateInjection)# 0 en 1?
                        sleep(1)

                    elif cardData == row[1] and row[0] == 0:
                        servoThread = threading.Thread(target=turnServo)
                        servoThread.start()
                        for i in range(3):
                            GPIO.output(ledGreen, False)
                            sleep(0.3)
                            GPIO.output(ledGreen, True)
                            sleep(0.3)
                        #dataID = gD.getDataWhere('customerID', 'customerInfo', 'RFIDNumber={}'.format(row[1]))
                        updateInjection = ('customerID = ' + str(row[2]))
                        gD.updateData('loginInfo', 'loggedIn = true', updateInjection)# 0 en 1?
                        sleep(1)

                    elif cardData != row[1] and rowCounter == len(dbData):
                        print("niet oke")
                        GPIO.output(ledGreen, False)
                        for i in range(5):
                            GPIO.output(ledRed, True)
                            sleep(0.5)
                            GPIO.output(ledRed, False)
                            sleep(0.5)
                        sleep(1)
                        GPIO.output(ledGreen, True)
            rowCounter += 1
        sleep(0.1)
示例#3
0
def scheduledTask():
    user = os.getenv('user')
    password = os.getenv('password')
    updateData(user, password)
示例#4
0
def login():
    """
        Here we read a rfid card and try to log the user in.
        firstly we get the rfidCards from the database.
    """
    dbData = gD.getData('loggedIn, rfidNumber, customerID', 'loginInfo')

    global cardA, keypad, backData, scanPass
    while True:
        breakOut = reader(False)
        cardData = backData
        cardData = str(cardData)
        backData = ""
        if keypad.getKey() == "*" or breakOut == True:
            sleep(1)
            if scanPass != "":
                close(scanPass)
                scanPass = ""
            #turn off all led colors
            GPIO.output(ledRed, False)
            GPIO.output(ledGreen, False)
            GPIO.output(ledBlue, False)
            break

        else:
            rowCounter = 1
            for row in dbData:
                if cardData == row[1] and row[0] == 1:
                    servoThread = threading.Thread(target=turnServo)
                    servoThread.start()
                    for i in range(3):
                        GPIO.output(ledGreen, False)
                        sleep(0.3)
                        GPIO.output(ledGreen, True)
                        sleep(0.3)
                    updateInjection = ('customerID = ' + str(row[2]))
                    gD.updateData('loginInfo', 'loggedIn = false',
                                  updateInjection)  # 0 en 1?
                    sleep(1)

                elif cardData == row[1] and row[0] == 0:
                    servoThread = threading.Thread(target=turnServo)
                    servoThread.start()
                    for i in range(3):
                        GPIO.output(ledGreen, False)
                        sleep(0.3)
                        GPIO.output(ledGreen, True)
                        sleep(0.3)
                    updateInjection = ('customerID = ' + str(row[2]))
                    gD.updateData('loginInfo', 'loggedIn = true',
                                  updateInjection)  # 0 en 1?
                    sleep(1)

                elif cardData != row[1] and rowCounter == len(dbData):
                    print("niet oke")
                    GPIO.output(ledGreen, False)
                    for i in range(5):
                        GPIO.output(ledRed, True)
                        sleep(0.5)
                        GPIO.output(ledRed, False)
                        sleep(0.5)
                    sleep(1)
                    GPIO.output(ledGreen, True)
            rowCounter += 1
        sleep(0.1)