diff --git a/adafruit_pyportal/__init__.py b/adafruit_pyportal/__init__.py index bb432dc..3afa844 100755 --- a/adafruit_pyportal/__init__.py +++ b/adafruit_pyportal/__init__.py @@ -128,7 +128,8 @@ def __init__( success_callback=None, esp=None, external_spi=None, - debug=False + debug=False, + secrets_data=None, ): graphics = Graphics( @@ -166,6 +167,7 @@ def __init__( image_position=image_position, image_dim_json_path=image_dim_json_path, debug=debug, + secrets_data=secrets_data, ) self.url = url diff --git a/adafruit_pyportal/network.py b/adafruit_pyportal/network.py index 9f5a48a..810c91e 100755 --- a/adafruit_pyportal/network.py +++ b/adafruit_pyportal/network.py @@ -28,7 +28,6 @@ # pylint: disable=unused-import from adafruit_portalbase.network import ( NetworkBase, - secrets, CONTENT_JSON, CONTENT_TEXT, ) @@ -74,6 +73,7 @@ def __init__( image_resize=None, image_position=None, image_dim_json_path=None, + secrets_data=None, ): wifi = WiFi(status_neopixel=status_neopixel, esp=esp, external_spi=external_spi) @@ -81,6 +81,7 @@ def __init__( wifi, extract_values=extract_values, debug=debug, + secrets_data=secrets_data, ) self._convert_image = convert_image @@ -89,7 +90,6 @@ def __init__( self._image_resize = image_resize self._image_position = image_position self._image_dim_json_path = image_dim_json_path - gc.collect() @property @@ -97,14 +97,13 @@ def ip_address(self): """Return the IP Address nicely formatted""" return self._wifi.esp.pretty_ip(self._wifi.esp.ip_address) - @staticmethod - def image_converter_url(image_url, width, height, color_depth=16): + def image_converter_url(self, image_url, width, height, color_depth=16): """Generate a converted image url from the url passed in, with the given width and height. aio_username and aio_key must be set in secrets.""" try: - aio_username = secrets["aio_username"] - aio_key = secrets["aio_key"] + aio_username = self._secrets["aio_username"] + aio_key = self._secrets["aio_key"] except KeyError as error: raise KeyError( "\n\nOur image converter service require a login/password to rate-limit. Please register for a free adafruit.io account and place the user/key in your secrets file under 'aio_username' and 'aio_key'" # pylint: disable=line-too-long