Skip to content

Commit c676edc

Browse files
authored
update code.py to settings.toml also
1 parent 6686a6c commit c676edc

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

  • PyPortal/PyPortal_Google_Calendar

PyPortal/PyPortal_Google_Calendar/code.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-FileCopyrightText: 2021 Brent Rubell, written for Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
4+
import os
45
import time
56
from adafruit_oauth2 import OAuth2
67
from adafruit_display_shapes.line import Line
@@ -42,16 +43,6 @@
4243
6: "Sunday",
4344
}
4445

45-
# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and
46-
# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other
47-
# source control.
48-
# pylint: disable=no-name-in-module,wrong-import-order
49-
try:
50-
from secrets import secrets
51-
except ImportError:
52-
print("WiFi secrets are kept in secrets.py, please add them there!")
53-
raise
54-
5546
# Create the PyPortal object
5647
pyportal = PyPortal()
5748
r = rtc.RTC()
@@ -63,18 +54,18 @@
6354
scopes = ["https://www.googleapis.com/auth/calendar.readonly"]
6455
google_auth = OAuth2(
6556
pyportal.network.requests,
66-
secrets["google_client_id"],
67-
secrets["google_client_secret"],
57+
os.getenv("GOOGLE_CLIENT_ID"),
58+
os.getenv("GOOGLE_CLIENT_SECRET"),
6859
scopes,
69-
secrets["google_access_token"],
70-
secrets["google_refresh_token"],
60+
os.getenv("GOOGLE_ACCESS_TOKEN"),
61+
os.getenv("GOOGLE_REFRESH_TOKEN"),
7162
)
7263

7364

7465
def get_current_time(time_max=False):
7566
"""Gets local time from Adafruit IO and converts to RFC3339 timestamp."""
7667
# Get local time from Adafruit IO
77-
pyportal.get_local_time(secrets["timezone"])
68+
pyportal.get_local_time(os.getenv("TIMEZONE"))
7869
# Format as RFC339 timestamp
7970
cur_time = r.datetime
8071
if time_max: # maximum time to fetch events is midnight (4:59:59UTC)

0 commit comments

Comments
 (0)