def get_access(rfid):
    "given an integer rfid card number, return None or a tuple of (username,allowed)"

    re_read_file()

    m = hashlib.sha224()

    # don't ask.  this is the way it was done so we have to also
    #becausejoe
    #
    rfidStr = "%.10d" % (int(rfid))
    m.update(str(rfidStr).encode())

    rfid_hash = m.hexdigest()
    botlog.debug('rfid_hash: %s' % rfid_hash)

    if rfid_hash not in card_data:
        return None

    return card_data[rfid_hash]
예제 #2
0
def get_access(rfid) :
    "given an integer rfid card number, return None or a tuple of (username,allowed)"

    re_read_file()

    m = hashlib.sha224()

    # don't ask.  this is the way it was done so we have to also
    #becausejoe
    #
    rfidStr = "%.10d"%(int(rfid))
    m.update(str(rfidStr).encode())

    
    rfid_hash = m.hexdigest()
    botlog.debug( 'rfid_hash: %s' % rfid_hash)


    if rfid_hash not in card_data :
        return None

    return card_data[rfid_hash]
예제 #3
0
while True:

    try:
        blinker += 1
        if blinker % 10 == 0:
            door_hw.green(False)
        sleep(.1)
        door_hw.green(True)

        # Get a card
        #
        rfid_str = reader.get_card()
        if not rfid_str:
            continue

        botlog.debug('RFID string >>%s<<' % rfid_str)

        # Several things can happen:
        # 1. some error in reading.
        # 2. good card, not allowed
        # 3. good card, allowed: yay!
        # 4. bad card from some reason
        # 5. unknown card
        try:
            rfid = int(rfid_str)

            access = authenticate.get_access(rfid)

            if access:
                (username, allowed) = access
예제 #4
0
파일: door.py 프로젝트: MomentumV/doorbot
while True :

    try :
        blinker += 1
        if blinker%10 == 0 :
            door_hw.green(False)
        sleep(.1)
        door_hw.green(True)

        # Get a card
        #
        rfid_str = reader.get_card()
        if not rfid_str :
            continue

        botlog.debug( 'RFID string >>%s<<' % rfid_str)

        # Several things can happen:
        # 1. some error in reading.
        # 2. good card, not allowed
        # 3. good card, allowed: yay!
        # 4. bad card from some reason
        # 5. unknown card
        try :
            rfid = int(rfid_str)

            access = authenticate.get_access(rfid)


            if access :
                (username,allowed) = access