From a69f2a9f4f987afb8bc389b03f9ecbfd1d7e0d3d Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 3 Nov 2020 10:23:25 -0800 Subject: [PATCH 1/2] Handle app/javascript as json. Fix missing text position error --- adafruit_pyportal.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index fb8099e..cb2dd44 100755 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -375,7 +375,7 @@ def __init__( self.set_caption(caption_text, caption_position, caption_color) if text_font: - if isinstance(text_position[0], (list, tuple)): + if text_position is not None and isinstance(text_position[0], (list, tuple)): num = len(text_position) if not text_wrap: text_wrap = [0] * num @@ -933,6 +933,8 @@ def fetch(self, refresh_url=None, timeout=10): content_type = CONTENT_IMAGE elif "application/json" in headers["content-type"]: content_type = CONTENT_JSON + elif "application/javascript" in headers["content-type"]: + content_type = CONTENT_JSON else: print( "HTTP Error {}: {}".format(r.status_code, r.reason.decode("utf-8")) From 1dcd993a0dc5f658d2cdebbebfc038422b264199 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Tue, 3 Nov 2020 10:25:11 -0800 Subject: [PATCH 2/2] Black formatted --- adafruit_pyportal.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index cb2dd44..75744dc 100755 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -375,7 +375,9 @@ def __init__( self.set_caption(caption_text, caption_position, caption_color) if text_font: - if text_position is not None and isinstance(text_position[0], (list, tuple)): + if text_position is not None and isinstance( + text_position[0], (list, tuple) + ): num = len(text_position) if not text_wrap: text_wrap = [0] * num @@ -819,8 +821,8 @@ def _connect_esp(self): @staticmethod def image_converter_url(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.""" + 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"] @@ -1163,8 +1165,7 @@ def show_QR( self._qr_only = hide_background def hide_QR(self): # pylint: disable=invalid-name - """Clear any QR codes that are currently on the screen - """ + """Clear any QR codes that are currently on the screen""" if self._qr_only: board.DISPLAY.show(self.splash)