def read_card_data(csv_filename): "return a dictionary of (username,key,allowed) indexed by hashed rfid" try: f = open(csv_filename) lines = f.read().splitlines() f.close() except: botlog.critical("authenticate can't read CSV %s" % csv_filename) return {} cd = {} for l in lines[1:]: try: (username, value, key, allowed, hashedCard, lastAccessed) = [x[1] for x in csv_line.findall(l)] # throw away value(?) and lastAccessed cd[hashedCard] = (username, allowed) except: botlog.error('authenticate CSV fail: %s' % l) botlog.info("authenticate read CSV %s %d entries" % (csv_filename, len(cd))) return cd
def read_card_data(csv_filename) : "return a dictionary of (username,key,allowed) indexed by hashed rfid" try : f = open(csv_filename) lines = f.read().splitlines() f.close() except : botlog.critical( "authenticate can't read CSV %s" % csv_filename) return {} cd = {} for l in lines[1:] : try : (username,value,key,allowed,hashedCard,lastAccessed) = [x[1] for x in csv_line.findall(l)] # throw away value(?) and lastAccessed cd[hashedCard] = (username,allowed) except : botlog.error( 'authenticate CSV fail: %s' % l) botlog.info( "authenticate read CSV %s %d entries" % (csv_filename, len(cd))) return cd
from time import sleep import re import setup import traceback from setup import botlog, reader, SERIAL_BAUD_RATE import authenticate import door_hw botlog.info('%s Starting.' % setup.botname) reader.initialize(baud_rate=setup.SERIAL_BAUD_RATE) blinker = 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:
from time import sleep import re import setup import traceback from setup import botlog, reader, SERIAL_BAUD_RATE import authenticate import door_hw botlog.info( '%s Starting.' % setup.botname) reader.initialize(baud_rate=setup.SERIAL_BAUD_RATE) blinker = 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)