From a4cbaecf301a868bdc86f0c0beeed40e9c3eb543 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 18 Sep 2023 16:16:20 -0500 Subject: [PATCH 1/8] "fix rtd theme " --- docs/conf.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 1c783de..745db70 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -110,19 +110,10 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get("READTHEDOCS", None) == "True" - -if not on_rtd: # only import and set the theme if we're building docs locally - try: - import sphinx_rtd_theme - - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] - except: - html_theme = "default" - html_theme_path = ["."] -else: - html_theme_path = ["."] +import sphinx_rtd_theme + +html_theme = "sphinx_rtd_theme" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From adcc0a5b797d73a68c50fffb45a22f5edbec213f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Oct 2023 14:30:31 -0500 Subject: [PATCH 2/8] unpin sphinx and add sphinx-rtd-theme to docs reqs Signed-off-by: foamyguy --- docs/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 797aa04..979f568 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,5 +2,6 @@ # # SPDX-License-Identifier: Unlicense -sphinx>=4.0.0 +sphinx sphinxcontrib-jquery +sphinx-rtd-theme From f76e4f13ba7f4d71603f0c842eb6d78895b04d8d Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Thu, 29 Feb 2024 07:36:40 -0800 Subject: [PATCH 3/8] Fix README requirements --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index 66eab38..462506b 100644 --- a/README.rst +++ b/README.rst @@ -25,6 +25,8 @@ Dependencies This driver depends on: * `Adafruit CircuitPython `_ +* `Adafruit CircuitPython Connection Manager `_ +* `Adafruit CircuitPython Requests `_ Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading From 8582de9845002a35a95b6e83bd018417cacc4091 Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Thu, 29 Feb 2024 21:18:39 -0800 Subject: [PATCH 4/8] Update legacy set_socket examples --- examples/oauth2_simpletest_esp32spi.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/oauth2_simpletest_esp32spi.py b/examples/oauth2_simpletest_esp32spi.py index 404feae..5aeded5 100644 --- a/examples/oauth2_simpletest_esp32spi.py +++ b/examples/oauth2_simpletest_esp32spi.py @@ -4,10 +4,11 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_oauth2 import OAuth2 # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -36,9 +37,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -# Initialize a requests object -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set scope(s) of access required by the API you're using scopes = ["email"] From 7780308dc21701bfe7fdde8d258d9ddc371d44bc Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Fri, 1 Mar 2024 08:57:58 -0800 Subject: [PATCH 5/8] Fix get_radio_ssl_context --- examples/oauth2_simpletest_esp32spi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/oauth2_simpletest_esp32spi.py b/examples/oauth2_simpletest_esp32spi.py index 5aeded5..1172d5f 100644 --- a/examples/oauth2_simpletest_esp32spi.py +++ b/examples/oauth2_simpletest_esp32spi.py @@ -5,7 +5,6 @@ import busio from digitalio import DigitalInOut import adafruit_connection_manager -import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi import adafruit_requests @@ -38,7 +37,8 @@ print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) # Initialize a requests session -ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +pool = adafruit_connection_manager.get_radio_socketpool(esp) +ssl_context = adafruit_connection_manager.get_radio_ssl_context(esp) requests = adafruit_requests.Session(pool, ssl_context) # Set scope(s) of access required by the API you're using From 4e72bfa33c96d77e6a896a1081800654ca1eac9c Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 7 Oct 2024 09:24:05 -0500 Subject: [PATCH 6/8] remove deprecated get_html_theme_path() call Signed-off-by: foamyguy --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 745db70..48c80a9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -113,7 +113,6 @@ import sphinx_rtd_theme html_theme = "sphinx_rtd_theme" -html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, From 35e3fab741dd0fce6ebb41deda1e8944c63ea7ee Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 14 Jan 2025 11:32:34 -0600 Subject: [PATCH 7/8] add sphinx configuration to rtd.yaml Signed-off-by: foamyguy --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 33c2a61..88bca9f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,6 +8,9 @@ # Required version: 2 +sphinx: + configuration: docs/conf.py + build: os: ubuntu-20.04 tools: From 6afd7a59c5e8a782fbeb9d85ef32b905d65b7e20 Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Tue, 25 Feb 2025 17:29:04 -0800 Subject: [PATCH 8/8] Remove secrets --- examples/oauth2_simpletest.py | 26 +++++++++++--------------- examples/oauth2_simpletest_cpython.py | 18 ++++++------------ examples/oauth2_simpletest_esp32spi.py | 22 +++++++++------------- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/examples/oauth2_simpletest.py b/examples/oauth2_simpletest.py index c1c6881..878b83e 100644 --- a/examples/oauth2_simpletest.py +++ b/examples/oauth2_simpletest.py @@ -1,25 +1,23 @@ # SPDX-FileCopyrightText: 2020 Brent Rubell, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense + +from os import getenv import ssl import wifi import socketpool import adafruit_requests from adafruit_oauth2 import OAuth2 -# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and -# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: - from secrets import secrets -except ImportError: - print("Credentials and tokens are kept in secrets.py, please add them there!") - raise +# Get WiFi details and Google keys, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") +google_client_id = getenv("google_client_id") +google_client_secret = getenv("google_client_secret") -print("Connecting to %s" % secrets["ssid"]) -wifi.radio.connect(secrets["ssid"], secrets["password"]) -print("Connected to %s!" % secrets["ssid"]) +print(f"Connecting to {ssid}") +wifi.radio.connect(ssid, password) +print(f"Connected to {ssid}") pool = socketpool.SocketPool(wifi.radio) requests = adafruit_requests.Session(pool, ssl.create_default_context()) @@ -29,9 +27,7 @@ scopes = ["email"] # Initialize an OAuth2 object -google_auth = OAuth2( - requests, secrets["google_client_id"], secrets["google_client_secret"], scopes -) +google_auth = OAuth2(requests, google_client_id, google_client_secret, scopes) # Request device and user codes # https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes diff --git a/examples/oauth2_simpletest_cpython.py b/examples/oauth2_simpletest_cpython.py index cd3a43b..3fa8025 100644 --- a/examples/oauth2_simpletest_cpython.py +++ b/examples/oauth2_simpletest_cpython.py @@ -1,20 +1,16 @@ # SPDX-FileCopyrightText: 2020 Brent Rubell, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense + +from os import getenv import socket import ssl import adafruit_requests from adafruit_oauth2 import OAuth2 -# Add a secrets.py to your filesystem that has a dictionary called secrets with Google -# application tokens. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: - from secrets import secrets -except ImportError: - print("Credentials and tokens are kept in secrets.py, please add them there!") - raise +# Get Google keys, ensure these are setup in settings.toml +google_client_id = getenv("google_client_id") +google_client_secret = getenv("google_client_secret") requests = adafruit_requests.Session(socket, ssl.create_default_context()) @@ -22,9 +18,7 @@ scopes = ["email"] # Initialize an OAuth2 object -google_auth = OAuth2( - requests, secrets["google_client_id"], secrets["google_client_secret"], scopes -) +google_auth = OAuth2(requests, google_client_id, google_client_secret, scopes) # Request device and user codes # https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes diff --git a/examples/oauth2_simpletest_esp32spi.py b/examples/oauth2_simpletest_esp32spi.py index 1172d5f..1428acc 100644 --- a/examples/oauth2_simpletest_esp32spi.py +++ b/examples/oauth2_simpletest_esp32spi.py @@ -1,6 +1,8 @@ # SPDX-FileCopyrightText: 2020 Brent Rubell, written for Adafruit Industries # # SPDX-License-Identifier: Unlicense + +from os import getenv import board import busio from digitalio import DigitalInOut @@ -10,15 +12,11 @@ import adafruit_requests from adafruit_oauth2 import OAuth2 -# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and -# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other -# source control. -# pylint: disable=no-name-in-module,wrong-import-order -try: - from secrets import secrets -except ImportError: - print("Credentials and tokens are kept in secrets.py, please add them there!") - raise +# Get WiFi details and Google keys, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") +google_client_id = getenv("google_client_id") +google_client_secret = getenv("google_client_secret") esp32_cs = DigitalInOut(board.ESP_CS) esp32_ready = DigitalInOut(board.ESP_BUSY) @@ -30,7 +28,7 @@ print("Connecting to AP...") while not esp.is_connected: try: - esp.connect_AP(secrets["ssid"], secrets["password"]) + esp.connect_AP(ssid, password) except RuntimeError as e: print("could not connect to AP, retrying: ", e) continue @@ -45,9 +43,7 @@ scopes = ["email"] # Initialize an OAuth2 object -google_auth = OAuth2( - requests, secrets["google_client_id"], secrets["google_client_secret"], scopes -) +google_auth = OAuth2(requests, google_client_id, google_client_secret, scopes) # Request device and user codes # https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-1:-request-device-and-user-codes