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