I want to compare the value of an object I have in a json file to the current time then print a response but I keep getting an error when trying to get the value. The function that checks the value of 'delta' compared to time.time() is connected to a button. The buttons are connected to the objects themselves. How would I fix this? Here is the code:
class MainApp(App):
def build(self): # build() returns an instance
self.store = JsonStore("streak.json") # file that stores the streaks
return presentation
def check_streak(self, instance):
honey = self.store.get('delta')
if honey > time.time():
print("early") # test
if honey == time.time():
print("on time")
if honey < time.time():
print("late")
here is the object in the file:
{"first": {"action": "first", "action_num": "1", "seconds": 60, "score": 0, "delta": 1555714261.0438898}}
This is the error I get:
File "C:\Users\tonya\Desktop\realProjects\HaStreakual\HaStreakual.py", line 66, in check_streak
honey = self.store.get('delta')
File "C:\Python36\lib\site-packages\kivy\storage\__init__.py", line 159, in get
return self.store_get(key)
File "C:\Python36\lib\site-packages\kivy\storage\jsonstore.py", line 63, in store_get
return self._data[key]
KeyError: 'delta