Skip to content

Commit 65d8f70

Browse files
committed
Don't use secrets.py
1 parent 4f98554 commit 65d8f70

14 files changed

+62
-130
lines changed

examples/requests_wifi_adafruit_discord_active_online.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
# 600 = 10 mins, 900 = 15 mins, 1800 = 30 mins, 3600 = 1 hour
2727
sleep_time = 900
2828

29-
# this example uses settings.toml for credentials
30-
ssid = os.getenv("WIFI_SSID")
31-
appw = os.getenv("WIFI_PASSWORD")
29+
# Get WiFi details, ensure these are setup in settings.toml
30+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
31+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
3232

3333

3434
# Converts seconds to minutes/hours/days

examples/requests_wifi_api_discord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Ensure this is in settings.toml
2020
# "Discord_Authorization": "Request Header Auth here"
2121

22-
# Uses settings.toml for credentials
22+
# Get WiFi details, ensure these are setup in settings.toml
2323
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
2424
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
2525
Discord_Auth = os.getenv("Discord_Authorization")

examples/requests_wifi_api_fitbit.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@
3636
# Fitbit_First_Refresh_Token = "64 character string"
3737
# Fitbit_UserID = "UserID authorizing the ClientID"
3838

39+
# Get WiFi details, ensure these are setup in settings.toml
40+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
41+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
42+
3943
Fitbit_ClientID = os.getenv("Fitbit_ClientID")
4044
Fitbit_Token = os.getenv("Fitbit_Token")
4145
Fitbit_First_Refresh_Token = os.getenv(
4246
"Fitbit_First_Refresh_Token"
4347
) # overides nvm first run only
4448
Fitbit_UserID = os.getenv("Fitbit_UserID")
4549

46-
wifi_ssid = os.getenv("CIRCUITPY_WIFI_SSID")
47-
wifi_pw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
48-
4950
# Time between API refreshes
5051
# 300 = 5 mins, 900 = 15 mins, 1800 = 30 mins, 3600 = 1 hour
5152
sleep_time = 900
@@ -78,7 +79,7 @@ def time_calc(input_time):
7879
requests = adafruit_requests.Session(pool, ssl.create_default_context())
7980
while not wifi.radio.ipv4_address:
8081
try:
81-
wifi.radio.connect(wifi_ssid, wifi_pw)
82+
wifi.radio.connect(ssid, appw)
8283
except ConnectionError as e:
8384
print("Connection Error:", e)
8485
print("Retrying in 10 seconds")

examples/requests_wifi_api_github.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""DJDevon3 Adafruit Feather ESP32-S2 Github_API_Example"""
55
import gc
66
import json
7+
import os
78
import ssl
89
import time
910

@@ -12,23 +13,19 @@
1213

1314
import adafruit_requests
1415

15-
# Github developer token required.
16-
# Ensure these are uncommented and in secrets.py or .env
17-
# "Github_username": "Your Github Username",
18-
# "Github_token": "Your long API token",
19-
2016
# Initialize WiFi Pool (There can be only 1 pool & top of script)
2117
pool = socketpool.SocketPool(wifi.radio)
2218

2319
# Time between API refreshes
2420
# 900 = 15 mins, 1800 = 30 mins, 3600 = 1 hour
2521
sleep_time = 900
2622

27-
try:
28-
from secrets import secrets
29-
except ImportError:
30-
print("Secrets File Import Error")
31-
raise
23+
# Get WiFi details, ensure these are setup in settings.toml
24+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
25+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
26+
# Github developer token required.
27+
github_username = os.getenv("Github_username")
28+
github_token = os.getenv("Github_token")
3229

3330
if sleep_time < 60:
3431
sleep_time_conversion = "seconds"
@@ -43,16 +40,16 @@
4340
sleep_int = sleep_time / 60 / 60 / 24
4441
sleep_time_conversion = "days"
4542

46-
github_header = {"Authorization": " token " + secrets["Github_token"]}
47-
GH_SOURCE = "https://api.github.com/users/" + secrets["Github_username"]
43+
github_header = {"Authorization": " token " + github_token}
44+
GH_SOURCE = "https://api.github.com/users/" + github_username
4845

4946
# Connect to Wi-Fi
5047
print("\n===============================")
5148
print("Connecting to WiFi...")
5249
requests = adafruit_requests.Session(pool, ssl.create_default_context())
5350
while not wifi.radio.ipv4_address:
5451
try:
55-
wifi.radio.connect(secrets["ssid"], secrets["password"])
52+
wifi.radio.connect(ssid, appw)
5653
except ConnectionError as e:
5754
print("Connection Error:", e)
5855
print("Retrying in 10 seconds")

examples/requests_wifi_api_mastodon.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Coded for Circuit Python 8.0
44
"""DJDevon3 Adafruit Feather ESP32-S2 Mastodon_API_Example"""
55
import gc
6+
import os
67
import ssl
78
import time
89

@@ -29,11 +30,9 @@
2930
# 900 = 15 mins, 1800 = 30 mins, 3600 = 1 hour
3031
sleep_time = 900
3132

32-
try:
33-
from secrets import secrets
34-
except ImportError:
35-
print("Secrets File Import Error")
36-
raise
33+
# Get WiFi details, ensure these are setup in settings.toml
34+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
35+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
3736

3837

3938
# Converts seconds in minutes/hours/days
@@ -71,7 +70,7 @@ def time_calc(input_time):
7170
requests = adafruit_requests.Session(pool, ssl.create_default_context())
7271
while not wifi.radio.ipv4_address:
7372
try:
74-
wifi.radio.connect(secrets["ssid"], secrets["password"])
73+
wifi.radio.connect(ssid, appw)
7574
except ConnectionError as e:
7675
print("Connection Error:", e)
7776
print("Retrying in 10 seconds")

examples/requests_wifi_api_openskynetwork_private.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@
3030
# https://openskynetwork.github.io/opensky-api/rest.html#limitations
3131
sleep_time = 1800
3232

33-
# this example uses settings.toml for credentials
34-
# timezone offset is in seconds plus or minus GMT
35-
ssid = os.getenv("AP_SSID")
36-
appw = os.getenv("AP_PASSWORD")
33+
# Get WiFi details, ensure these are setup in settings.toml
34+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
35+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
3736
osnu = os.getenv("OSN_Username")
3837
osnp = os.getenv("OSN_Password")
3938

examples/requests_wifi_api_openskynetwork_private_area.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
# https://openskynetwork.github.io/opensky-api/rest.html#limitations
3333
sleep_time = 1800
3434

35-
# this example uses settings.toml for credentials
35+
# Get WiFi details, ensure these are setup in settings.toml
36+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
37+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
3638
# No token required, only website login
37-
ssid = os.getenv("AP_SSID")
38-
appw = os.getenv("AP_PASSWORD")
3939
osnu = os.getenv("OSN_Username")
4040
osnp = os.getenv("OSN_Password")
4141

examples/requests_wifi_api_openskynetwork_public.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
# https://openskynetwork.github.io/opensky-api/rest.html#limitations
2929
sleep_time = 1800
3030

31-
# Wifi credentials pulled from settings.toml
32-
ssid = os.getenv("AP_SSID")
33-
appw = os.getenv("AP_PASSWORD")
31+
# Get WiFi details, ensure these are setup in settings.toml
32+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
33+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
3434

3535
# Requests URL - icao24 is their endpoint required for a transponder
3636
# example https://opensky-network.org/api/states/all?icao24=a808c5

examples/requests_wifi_api_steam.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
# Steam Usernumber: Visit https://steamcommunity.com
1919
# click on your profile icon, your usernumber will be in the browser url.
2020

21-
# Ensure these are setup in settings.toml
21+
# Get WiFi details, ensure these are setup in settings.toml
22+
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
23+
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
2224
# Requires Steam Developer API key
23-
ssid = os.getenv("AP_SSID")
24-
appw = os.getenv("AP_PASSWORD")
2525
steam_usernumber = os.getenv("steam_id")
2626
steam_apikey = os.getenv("steam_api_key")
2727

examples/requests_wifi_api_twitch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# "Twitch_Client_Secret": "APP ID secret here",
2424
# "Twitch_UserID": "Your Twitch UserID here",
2525

26-
# Use settings.toml for credentials
26+
# Get WiFi details, ensure these are setup in settings.toml
2727
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
2828
appw = os.getenv("CIRCUITPY_WIFI_PASSWORD")
2929
twitch_client_id = os.getenv("Twitch_ClientID")

0 commit comments

Comments
 (0)