You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
637 B
27 lines
637 B
8 years ago
|
import time
|
||
|
import json
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
while True:
|
||
|
cardID = raw_input("Enter card ID: ")
|
||
|
event = {}
|
||
|
event["time"] = time.time()
|
||
|
event["cardID"] = cardID
|
||
|
event["name"] = ''
|
||
|
try:
|
||
|
with open('cards/' + cardID + '.json') as card_data:
|
||
|
data = json.load(card_data)
|
||
|
event["name"] = data['name']
|
||
|
except:
|
||
|
print "Card not registered."
|
||
|
history = []
|
||
|
try:
|
||
|
with open('history.json', 'r') as json_data:
|
||
|
history = json.load(json_data)
|
||
|
except:
|
||
|
print 'Initializing new history file.'
|
||
|
finally:
|
||
|
history.append(event)
|
||
|
with open('history.json', 'w') as outfile:
|
||
|
json.dump(history, outfile)
|
||
|
|