Skip to content

Commit 86168da

Browse files
authored
Merge pull request #137 from justmobilize/remove-secrets-and-more
Remove secrets and more
2 parents eb3518a + 402f808 commit 86168da

File tree

5 files changed

+21
-26
lines changed

5 files changed

+21
-26
lines changed

adafruit_pyportal/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def __init__( # noqa: PLR0912,PLR0913,PLR0915 Too many branches,Too many argume
124124
esp=None,
125125
external_spi=None,
126126
debug=False,
127-
secrets_data=None,
128127
):
129128
graphics = Graphics(
130129
default_bg=default_bg,
@@ -161,7 +160,6 @@ def __init__( # noqa: PLR0912,PLR0913,PLR0915 Too many branches,Too many argume
161160
image_position=image_position,
162161
image_dim_json_path=image_dim_json_path,
163162
debug=debug,
164-
secrets_data=secrets_data,
165163
)
166164

167165
self.url = url

adafruit_pyportal/network.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def __init__( # noqa: PLR0913 Too many arguments in function definition
8383
image_resize=None,
8484
image_position=None,
8585
image_dim_json_path=None,
86-
secrets_data=None,
8786
):
8887
if status_neopixel:
8988
status_led = neopixel.NeoPixel(status_neopixel, 1, brightness=0.2)
@@ -95,7 +94,6 @@ def __init__( # noqa: PLR0913 Too many arguments in function definition
9594
wifi,
9695
extract_values=extract_values,
9796
debug=debug,
98-
secrets_data=secrets_data,
9997
)
10098

10199
self._convert_image = convert_image
@@ -113,16 +111,16 @@ def ip_address(self):
113111

114112
def image_converter_url(self, image_url, width, height, color_depth=16):
115113
"""Generate a converted image url from the url passed in,
116-
with the given width and height. aio_username and aio_key must be
117-
set in secrets."""
114+
with the given width and height. ADAFRUIT_AIO_USERNAME and
115+
ADAFRUIT_AIO_KEY must be set in settings.toml."""
118116
try:
119-
aio_username = self._get_setting("AIO_USERNAME")
120-
aio_key = self._get_setting("AIO_KEY")
117+
aio_username = self._get_setting("ADAFRUIT_AIO_USERNAME")
118+
aio_key = self._get_setting("ADAFRUIT_AIO_KEY")
121119
except KeyError as error:
122120
raise KeyError(
123121
"\n\nOur image converter service require a login/password to rate-limit. "
124122
"Please register for a free adafruit.io account and place the user/key in "
125-
"your secrets file under 'aio_username' and 'aio_key'"
123+
"your settings.toml file under 'ADAFRUIT_AIO_USERNAME' and 'ADAFRUIT_AIO_KEY'"
126124
) from error
127125

128126
return IMAGE_CONVERTER_SERVICE % (

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"audiocore",
3838
"microcontroller",
3939
"neopixel",
40-
"secrets",
4140
"adafruit_sdcard",
4241
"storage",
4342
"sdcardio",

examples/pyportal_internet_json_fetching.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@
55
Example to illustrate the device capability to get json data
66
"""
77

8-
# NOTE: Make sure you've created your secrets.py file before running this example
9-
# https://learn.adafruit.com/adafruit-pyportal/internet-connect#whats-a-secrets-file-17-2
8+
# NOTE: Make sure you've created your settings.toml file before running this example
9+
# https://learn.adafruit.com/adafruit-pyportal/create-your-settings-toml-file
10+
from os import getenv
11+
1012
import adafruit_connection_manager
1113
import adafruit_requests
1214
import board
1315
from adafruit_esp32spi import adafruit_esp32spi
1416
from digitalio import DigitalInOut
1517

16-
# Get wifi details and more from a secrets.py file
17-
try:
18-
from secrets import secrets
19-
except ImportError:
20-
print("WiFi secrets are kept in secrets.py, please add them there!")
21-
raise
18+
# Get wifi details and more from a settings.toml file
19+
# tokens used by this Demo: CIRCUITPY_WIFI_SSID, CIRCUITPY_WIFI_PASSWORD
20+
ssid = getenv("CIRCUITPY_WIFI_SSID")
21+
password = getenv("CIRCUITPY_WIFI_PASSWORD")
2222

2323
print("ESP32 SPI webclient test")
2424

2525
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
26-
JSON_URL = "http://api.coindesk.com/v1/bpi/currentprice/USD.json"
26+
JSON_URL = "http://wifitest.adafruit.com/testwifi/sample.json"
2727

2828

2929
# ESP32 Pins:
@@ -41,20 +41,20 @@
4141
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
4242
print("ESP32 found and in idle mode")
4343
print("Firmware vers.", esp.firmware_version)
44-
print("MAC addr:", [hex(i) for i in esp.MAC_address])
44+
print("MAC addr:", ":".join("%02X" % byte for byte in esp.MAC_address))
4545

4646
for ap in esp.scan_networks():
47-
print("\t%s\t\tRSSI: %d" % (str(ap["ssid"], "utf-8"), ap["rssi"]))
47+
print("\t%-23s RSSI: %d" % (ap.ssid, ap.rssi))
4848

4949
print("Connecting to AP...")
5050
while not esp.is_connected:
5151
try:
52-
esp.connect_AP(secrets["ssid"], secrets["password"])
52+
esp.connect_AP(ssid, password)
5353
except RuntimeError as e:
5454
print("could not connect to AP, retrying: ", e)
5555
continue
56-
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
57-
print("My IP address is", esp.pretty_ip(esp.ip_address))
56+
print("Connected to", esp.ap_info.ssid, "\tRSSI:", esp.ap_info.rssi)
57+
print("My IP address is", esp.ipv4_address)
5858
print("IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com")))
5959
print("Ping google.com: %d ms" % esp.ping("google.com"))
6060

examples/pyportal_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
# NOTE: Make sure you've created your secrets.py file before running this example
6-
# https://learn.adafruit.com/adafruit-pyportal/internet-connect#whats-a-secrets-file-17-2
5+
# NOTE: Make sure you've created your settings.toml file before running this example
6+
# https://learn.adafruit.com/adafruit-pyportal/create-your-settings-toml-file
77
import board
88
from displayio import CIRCUITPYTHON_TERMINAL
99

0 commit comments

Comments
 (0)