diff --git a/examples/pastebin_aio_cpython.py b/examples/pastebin_aio_cpython.py index f6c94d1..c7c14e9 100644 --- a/examples/pastebin_aio_cpython.py +++ b/examples/pastebin_aio_cpython.py @@ -2,18 +2,14 @@ # # SPDX-License-Identifier: Unlicense +from os import getenv import ssl import socket import adafruit_requests as requests from adafruit_pastebin.adafruit_io import AIOPastebin -try: - from secrets import secrets -except ImportError: - print("Please place your auth/dev key in a secrets.py file!") - raise - -auth_key = secrets["auth_key"] +# Get PasteBin keys, ensure these are setup in your environment +auth_key = getenv("auth_key") session = requests.Session(socket, ssl_context=ssl.create_default_context()) diff --git a/examples/pastebin_gist_cpython.py b/examples/pastebin_gist_cpython.py index 2f599a4..6338b89 100644 --- a/examples/pastebin_gist_cpython.py +++ b/examples/pastebin_gist_cpython.py @@ -2,18 +2,14 @@ # # SPDX-License-Identifier: Unlicense +from os import getenv import ssl import socket import adafruit_requests as requests from adafruit_pastebin.gist import Gist -try: - from secrets import secrets -except ImportError: - print("Please place your auth/dev key in a secrets.py file!") - raise - -auth_key = secrets["auth_key"] +# Get PasteBin keys, ensure these are setup in your environment +auth_key = getenv("auth_key") session = requests.Session(socket, ssl_context=ssl.create_default_context()) diff --git a/examples/pastebin_simpletest.py b/examples/pastebin_simpletest.py index a2688d6..0fb9d23 100644 --- a/examples/pastebin_simpletest.py +++ b/examples/pastebin_simpletest.py @@ -2,24 +2,22 @@ # # SPDX-License-Identifier: Unlicense +from os import getenv import ssl import wifi import socketpool import adafruit_requests as requests from adafruit_pastebin.pastebin import PasteBin, ExpirationSetting, PrivacySetting -try: - from secrets import secrets -except ImportError: - print("Please place your auth/dev key in a secrets.py file!") - raise +# Get WiFi details and PasteBin keys, ensure these are setup in settings.toml +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") +auth_key = getenv("auth_key") -wifi.radio.connect(secrets["ssid"], secrets["password"]) +wifi.radio.connect(ssid, password) pool = socketpool.SocketPool(wifi.radio) session = requests.Session(pool, ssl.create_default_context()) -auth_key = secrets["auth_key"] - pastebin = PasteBin(session, auth_key) paste_url = pastebin.paste( "This is a test paste!", diff --git a/examples/pastebin_simpletest_cpython.py b/examples/pastebin_simpletest_cpython.py index 467faa4..af18de4 100644 --- a/examples/pastebin_simpletest_cpython.py +++ b/examples/pastebin_simpletest_cpython.py @@ -2,18 +2,14 @@ # # SPDX-License-Identifier: Unlicense +from os import getenv import ssl import socket import adafruit_requests as requests from adafruit_pastebin.pastebin import PasteBin, ExpirationSetting, PrivacySetting -try: - from secrets import secrets -except ImportError: - print("Please place your auth/dev key in a secrets.py file!") - raise - -auth_key = secrets["auth_key"] +# Get PasteBin keys, ensure these are setup in your environment +auth_key = getenv("auth_key") session = requests.Session(socket, ssl_context=ssl.create_default_context())