From c136e268e7f561e4cda913c3ec5c305a7fbc90f2 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 31 Aug 2020 15:38:06 -0700 Subject: [PATCH] linted out exceptionalization pylint errors --- adafruit_pyportal.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 42c2171..9f8515d 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -660,10 +660,10 @@ def get_local_time(self, location=None): try: aio_username = secrets["aio_username"] aio_key = secrets["aio_key"] - except KeyError: + except KeyError as error: raise KeyError( "\n\nOur time service requires 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 - ) + ) from error location = secrets.get("timezone", location) if location: @@ -686,10 +686,10 @@ def get_local_time(self, location=None): year_day = int(times[2]) week_day = int(times[3]) is_dst = None # no way to know yet - except KeyError: + except KeyError as error: raise KeyError( "Was unable to lookup the time, try setting secrets['timezone'] according to http://worldtimeapi.org/timezones" # pylint: disable=line-too-long - ) + ) from error year, month, mday = [int(x) for x in the_date.split("-")] the_time = the_time.split(".")[0] hours, minutes, seconds = [int(x) for x in the_time.split(":")] @@ -778,10 +778,10 @@ def image_converter_url(image_url, width, height, color_depth=16): try: aio_username = secrets["aio_username"] aio_key = secrets["aio_key"] - except KeyError: + 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 - ) + ) from error return IMAGE_CONVERTER_SERVICE % ( aio_username, @@ -813,10 +813,10 @@ def push_to_io(self, feed_key, data): try: aio_username = secrets["aio_username"] aio_key = secrets["aio_key"] - except KeyError: + except KeyError as error: raise KeyError( "Adafruit IO secrets are kept in secrets.py, please add them there!\n\n" - ) + ) from error wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager( self._esp, secrets, None @@ -970,13 +970,11 @@ def fetch(self, refresh_url=None, timeout=10): try: self.wget(image_url, filename, chunk_size=chunk_size) except OSError as error: - print(error) raise OSError( """\n\nNo writable filesystem found for saving datastream. Insert an SD card or set internal filesystem to be unsafe by setting 'disable_concurrent_write_protection' in the mount options in boot.py""" # pylint: disable=line-too-long - ) + ) from error except RuntimeError as error: - print(error) - raise RuntimeError("wget didn't write a complete file") + raise RuntimeError("wget didn't write a complete file") from error if iwidth < iheight: pwidth = int( self._image_resize[1]