Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions examples/pastebin_aio_cpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
10 changes: 3 additions & 7 deletions examples/pastebin_gist_cpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
14 changes: 6 additions & 8 deletions examples/pastebin_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
10 changes: 3 additions & 7 deletions examples/pastebin_simpletest_cpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down