Skip to content

Commit acbbbc3

Browse files
author
brentru
committed
add magtag gcal code, blacked and linted
1 parent cc13cbc commit acbbbc3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

MagTag_Google_Calendar/authenticator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Google OAuth2.0 Workflow for MagTag
1+
# SPDX-FileCopyrightText: 2021 Brent Rubell, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
24
import ssl
35
import board
46
import wifi
@@ -27,6 +29,7 @@
2729
pool = socketpool.SocketPool(wifi.radio)
2830
requests = requests.Session(pool, ssl.create_default_context())
2931

32+
# DisplayIO setup
3033
font_small = bitmap_font.load_font("/fonts/Arial-12.pcf")
3134
font_large = bitmap_font.load_font("/fonts/Arial-14.pcf")
3235

MagTag_Google_Calendar/code.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# MagTag Google Calendar Event Viewer
2-
# Brent Rubell for Adafruit Industries, 2021
1+
# SPDX-FileCopyrightText: 2021 Brent Rubell, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: Unlicense
34
import time
45
import ssl
56
import board
@@ -55,9 +56,6 @@
5556
pool = socketpool.SocketPool(wifi.radio)
5657
requests = requests.Session(pool, ssl.create_default_context())
5758

58-
magtag = MagTag()
59-
r = rtc.RTC()
60-
6159
# Initialize an OAuth2 object with GCal API scope
6260
scopes = ["https://www.googleapis.com/auth/calendar.readonly"]
6361
google_auth = OAuth2(
@@ -69,8 +67,6 @@
6967
secrets["google_refresh_token"],
7068
)
7169

72-
if not google_auth.refresh_access_token():
73-
raise RuntimeError("Unable to refresh access token - has the token been revoked?")
7470

7571
def get_current_time(time_max=False):
7672
"""Gets local time from Adafruit IO and converts to RFC3339 timestamp."""
@@ -189,6 +185,11 @@ def display_calendar_events(resp_events):
189185
)
190186
magtag.splash.append(label_event_desc)
191187

188+
189+
# Create a new MagTag object
190+
magtag = MagTag()
191+
r = rtc.RTC()
192+
192193
# DisplayIO Setup
193194
magtag.set_background(0xFFFFFF)
194195

0 commit comments

Comments
 (0)