|
|
@ -1,4 +1,5 @@
|
|
|
|
import time , json
|
|
|
|
import time , json
|
|
|
|
|
|
|
|
#import simplejson as json
|
|
|
|
import RPi.GPIO as GPIO
|
|
|
|
import RPi.GPIO as GPIO
|
|
|
|
import keyboard
|
|
|
|
import keyboard
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
@ -44,10 +45,15 @@ if __name__ == '__main__':
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
print "Enter card ID:"
|
|
|
|
print ("Enter card ID:")
|
|
|
|
|
|
|
|
cardID=''
|
|
|
|
cardID_input = keyboard.record(until='enter')
|
|
|
|
cardID_input = keyboard.record(until='enter')
|
|
|
|
cardID = keyboard.get_typed_strings(cardID_input).next()
|
|
|
|
cardID_gen = keyboard.get_typed_strings(cardID_input)
|
|
|
|
|
|
|
|
for i in cardID_gen:
|
|
|
|
|
|
|
|
cardID += i
|
|
|
|
event = {}
|
|
|
|
event = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event["time"] = time.time()
|
|
|
|
event["time"] = time.time()
|
|
|
|
event["cardID"] = cardID
|
|
|
|
event["cardID"] = cardID
|
|
|
|
event["name"] = ''
|
|
|
|
event["name"] = ''
|
|
|
@ -97,15 +103,19 @@ if __name__ == '__main__':
|
|
|
|
GPIO.output(pin_config['fridge_red_LED'], GPIO.LOW)
|
|
|
|
GPIO.output(pin_config['fridge_red_LED'], GPIO.LOW)
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
GPIO.output(pin_config['tools_red_LED'], GPIO.LOW)
|
|
|
|
wait = False
|
|
|
|
wait = False
|
|
|
|
except:
|
|
|
|
except Exception as e:
|
|
|
|
btnBlink()
|
|
|
|
btnBlink()
|
|
|
|
print "Card not registered."
|
|
|
|
print( "Card not registered.")
|
|
|
|
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
|
|
|
|
history = []
|
|
|
|
history = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
with open('history.json', 'r') as json_data:
|
|
|
|
with open('history.json', 'r') as json_data:
|
|
|
|
history = json.load(json_data)
|
|
|
|
history = json.load(json_data)
|
|
|
|
except:
|
|
|
|
|
|
|
|
print 'Initializing new history file.'
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
print('Initializing new history file.')
|
|
|
|
|
|
|
|
print(e)
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
history.append(event)
|
|
|
|
history.append(event)
|
|
|
|
with open('history.json', 'w') as outfile:
|
|
|
|
with open('history.json', 'w') as outfile:
|
|
|
|