|
1 | 1 | # SPDX-FileCopyrightText: 2021 Brent Rubell, written for Adafruit Industries |
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: Unlicense |
| 4 | +import os |
4 | 5 | import time |
5 | 6 | from adafruit_oauth2 import OAuth2 |
6 | 7 | from adafruit_display_shapes.line import Line |
|
42 | 43 | 6: "Sunday", |
43 | 44 | } |
44 | 45 |
|
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 | | - |
55 | 46 | # Create the PyPortal object |
56 | 47 | pyportal = PyPortal() |
57 | 48 | r = rtc.RTC() |
|
63 | 54 | scopes = ["https://www.googleapis.com/auth/calendar.readonly"] |
64 | 55 | google_auth = OAuth2( |
65 | 56 | 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"), |
68 | 59 | scopes, |
69 | | - secrets["google_access_token"], |
70 | | - secrets["google_refresh_token"], |
| 60 | + os.getenv("GOOGLE_ACCESS_TOKEN"), |
| 61 | + os.getenv("GOOGLE_REFRESH_TOKEN"), |
71 | 62 | ) |
72 | 63 |
|
73 | 64 |
|
74 | 65 | def get_current_time(time_max=False): |
75 | 66 | """Gets local time from Adafruit IO and converts to RFC3339 timestamp.""" |
76 | 67 | # Get local time from Adafruit IO |
77 | | - pyportal.get_local_time(secrets["timezone"]) |
| 68 | + pyportal.get_local_time(os.getenv("TIMEZONE")) |
78 | 69 | # Format as RFC339 timestamp |
79 | 70 | cur_time = r.datetime |
80 | 71 | if time_max: # maximum time to fetch events is midnight (4:59:59UTC) |
|
0 commit comments