Member Check-In System
Super hacky, eventually to be improved member check-in system with smart cards.
reader.py
#! /usr/bin/env python import string,commands,os from sys import stdin, exc_info from time import sleep from smartcard.CardMonitoring import CardMonitor, CardObserver from smartcard.util import * current=open("whoishere","r").read().split("\n") mute=False class printobserver(CardObserver): def update(self, observable, (addedcards, removedcards)): global current global mute for card in addedcards: print "+"+string.replace(toHexString(card.atr)," ",'') dump=commands.getoutput("pkcs15-tool -D") if "UASID:" in dump: id=dump[dump.find("UASID:")+6:] id=id[0:id.find("]")] current=open("whoishere","r").read().split("\n") if id != "" and id not in current: print id,"has checked in at the space." if mute == False: os.system("echo '"+id+" has checked in at the space.' > /uas/irc/irc") f=open("/uas/ocs/log","a") f.write(id+" was here\n") f.close() f=open("/uas/smart/whoishere","a") f.write(id+"\n") f.close() current.append(id) os.system("mplayer /uas/hal9001/welcome_back.wav") else: print id,"Already Checked in or Empty ID" os.system("mplayer /uas/hal9001/welcome_back.wav") for card in removedcards: print "-"+string.replace(toHexString(card.atr)," ",'') try: cardmonitor = CardMonitor() cardobserver = printobserver() cardmonitor.addObserver(cardobserver) while True: todo=raw_input("").strip() if "add user " in todo: id = todo[9:] if id != "": commands.getoutput("pkcs15-init -TEC --label 'UASID:"+id+"' --no-so-pin") print "That could of work, or not, whatever" elif "mute on" in todo: mute=True print "Mute on" elif "mute off" in todo: mute=False print "Mute off" cardmonitor.deleteObserver(cardobserver) except: print exc_info()[0], ':', exc_info()[1]