-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove secrets usage #32
Conversation
@FoamyGuy this should be the last batch (11) of secret removals. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this page needs updated when this gets merged https://learn.adafruit.com/bluetooth-le-broadcastnet-sensor-node-raspberry-pi-wifi-bridge/install-pi-bridge-software. It's 🛏️ ⌚ for me though. Will merge and update page tomorrow.
# Get Adafruit IO keys, ensure these are setup in your environment | ||
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.) | ||
aio_username = getenv("ADAFRUIT_AIO_USERNAME") | ||
aio_key = getenv("ADAFRUIT_AIO_KEY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is meant for raspberry pi, so settings.toml
is not going to automatically make it's way into environment variables in that environment.
We could instruct users to export the variables needed before running the script, but that would need to be done each time, so then we could point them to .bashrc or similar, but I'm not sure this is really the best option.
Maybe the script should be modified to parse the toml file and set environment variables from before accessing them. That way the user doesn't need to do anything manual and the experience is mostly the same as on MCU.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FoamyGuy how about this (it's what I do for mine):
import tomllib
# Get Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
with open("settings.toml", "rb") as toml_file:
settings = tomllib.load(toml_file)
aio_username = settings("ADAFRUIT_AIO_USERNAME")
aio_key = settings("ADAFRUIT_AIO_KEY")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, however until we raise the minimum supported python version of the libraries and Blinka I think we should have code that is compatible with both tomllib
and toml
. And I think have a note in the error message if it fails to import either that they can install it from pip.
I'll make a note to discuss minimum supported version in the weeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FoamyGuy, do we need to add toml
to Blink first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If/when we add settings.toml
loading to Blinka then yes I think we should add it as a req for any versions prior to it becoming built-in.
If the code is going to live in the example script like the one in this repo then I don't think we need to add it as a dependency for Blinka yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FoamyGuy so this should now be:
from adafruit_blinka import load_settings_toml
...
# Get Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
load_settings_toml()
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that looks correct to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here: dbd3761
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into this and thinking about the changes needed to the guide I think there is actually a little more to consider for this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_BroadcastNet to 0.12.13 from 0.12.12: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_BroadcastNet#32 from justmobilize/remove-secrets-usage
Remove secrets usage