Example #1
0
		cur.execute("UPDATE `control` SET `Value`=0 WHERE `Parameter`='AddKey'")
		cur.execute("UPDATE `control` SET `Value`='' WHERE `Parameter`='NewName'")
		cur.execute("UPDATE `control` SET `Value`='' WHERE `Parameter`='NewGroup'")
		cur.execute("UPDATE `control` SET `Value`='' WHERE `Parameter`='NewActive'")
		cur.execute("UPDATE `control` SET `Value`='' WHERE `Parameter`='NewExpires'")
            else:
                try:			
                    cur.execute("SELECT * FROM `keys` WHERE `Hex`='{0}'".format(key))
                    card=cur.fetchall()
                    logging.debug("DB record: %s", (card))
                    if int(card[0][1])==dec:
                        #Cheking if active key, expiry date etc.
                        #Get username
                        name=card[0][2]
                        #Odpri vrata
			door.toggle(name,2)
                    else:
                        #logging.info("Card didn't pass the second check")
                        #Pisi v AccessLog
                        sql="INSERT INTO AccessLog(`Key`, `Action`) VALUES (%s,'Unknown card')"
                        cur.execute(sql, (dec))
                        #logging.debug("Wrote UNKNOWN CARD to DB: {0}".format(sql))               
                except IndexError:
                    logging.info("Card not recorded in the database.")
                    #Pisi v AccessLog
                    sql="INSERT INTO AccessLog(`Key`, `Action`) VALUES (%s,'Unknown card')"
                    cur.execute(sql, (dec))
                    logging.debug("Wrote UNKNOWN CARD to DB: {0}".format(sql))
                    print (dec)
                    print (key)
                readout=""
Example #2
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"