Skip to content

Commit

Permalink
Merge pull request #5 from steoj/patch-1
Browse files Browse the repository at this point in the history
fix: handle api error on calendar fetch
  • Loading branch information
stenjo authored Sep 29, 2022
2 parents 2e80994 + 3f05256 commit 9e695a0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions middag.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ def main(argv):
# Call the Calendar API
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
# print('Getting the upcoming 10 events')
events_result = service.events().list(calendarId='parterapeutene.no_e1or90m2lp6p523ma7u15v2pc0@group.calendar.google.com', timeMin=now,
maxResults=7, singleEvents=True,
orderBy='startTime').execute()
try:
events_result = service.events().list(calendarId='parterapeutene.no_e1or90m2lp6p523ma7u15v2pc0@group.calendar.google.com', timeMin=now,
maxResults=7, singleEvents=True,
orderBy='startTime').execute()
except:
time.sleep(2)
continue

events = events_result.get('items', [])

msg = ''
Expand Down

0 comments on commit 9e695a0

Please sign in to comment.