fixing error handling for json parsing
This commit is contained in:
+3
-1
@@ -46,7 +46,9 @@ class CalGrab(object):
|
|||||||
print('No upcoming events found.')
|
print('No upcoming events found.')
|
||||||
return
|
return
|
||||||
|
|
||||||
events = [Event.get_from_gcal_api_json(json) for json in events]
|
events = [i for i in [Event.get_from_gcal_api_json(json) for json in events] if i is not None]
|
||||||
|
print(events)
|
||||||
|
|
||||||
for callback in self.callbacks:
|
for callback in self.callbacks:
|
||||||
callback(events)
|
callback(events)
|
||||||
if time_to_update > 0 and (now - start).total_seconds() > time_to_update:
|
if time_to_update > 0 and (now - start).total_seconds() > time_to_update:
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ class Event(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_from_gcal_api_json(json):
|
def get_from_gcal_api_json(json):
|
||||||
print(json['start'].get('dateTime'))
|
try:
|
||||||
return Event(
|
print(json['start'].get('dateTime'))
|
||||||
json['summary'] if 'summary' in json else "No Title",
|
return Event(
|
||||||
parse(json['start'].get('dateTime')),
|
json['summary'] if 'summary' in json else "No Title",
|
||||||
parse(json['end'].get('dateTime'))
|
parse(json['start'].get('dateTime')),
|
||||||
)
|
parse(json['end'].get('dateTime'))
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return None
|
||||||
|
|||||||
@@ -22,5 +22,4 @@ rsa==4.8
|
|||||||
six==1.16.0
|
six==1.16.0
|
||||||
uritemplate==4.1.1
|
uritemplate==4.1.1
|
||||||
urllib3==1.26.9
|
urllib3==1.26.9
|
||||||
adafruit-circuitpython-charlcd
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user