Skip to content

Commit 29f08ca

Browse files
authored
Merge pull request #84 from makermelissa/master
Fixed exceptionalization pylint errors
2 parents f53287d + c136e26 commit 29f08ca

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

adafruit_pyportal.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,10 @@ def get_local_time(self, location=None):
660660
try:
661661
aio_username = secrets["aio_username"]
662662
aio_key = secrets["aio_key"]
663-
except KeyError:
663+
except KeyError as error:
664664
raise KeyError(
665665
"\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
666-
)
666+
) from error
667667

668668
location = secrets.get("timezone", location)
669669
if location:
@@ -686,10 +686,10 @@ def get_local_time(self, location=None):
686686
year_day = int(times[2])
687687
week_day = int(times[3])
688688
is_dst = None # no way to know yet
689-
except KeyError:
689+
except KeyError as error:
690690
raise KeyError(
691691
"Was unable to lookup the time, try setting secrets['timezone'] according to http://worldtimeapi.org/timezones" # pylint: disable=line-too-long
692-
)
692+
) from error
693693
year, month, mday = [int(x) for x in the_date.split("-")]
694694
the_time = the_time.split(".")[0]
695695
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):
778778
try:
779779
aio_username = secrets["aio_username"]
780780
aio_key = secrets["aio_key"]
781-
except KeyError:
781+
except KeyError as error:
782782
raise KeyError(
783783
"\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
784-
)
784+
) from error
785785

786786
return IMAGE_CONVERTER_SERVICE % (
787787
aio_username,
@@ -813,10 +813,10 @@ def push_to_io(self, feed_key, data):
813813
try:
814814
aio_username = secrets["aio_username"]
815815
aio_key = secrets["aio_key"]
816-
except KeyError:
816+
except KeyError as error:
817817
raise KeyError(
818818
"Adafruit IO secrets are kept in secrets.py, please add them there!\n\n"
819-
)
819+
) from error
820820

821821
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(
822822
self._esp, secrets, None
@@ -970,13 +970,11 @@ def fetch(self, refresh_url=None, timeout=10):
970970
try:
971971
self.wget(image_url, filename, chunk_size=chunk_size)
972972
except OSError as error:
973-
print(error)
974973
raise OSError(
975974
"""\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
976-
)
975+
) from error
977976
except RuntimeError as error:
978-
print(error)
979-
raise RuntimeError("wget didn't write a complete file")
977+
raise RuntimeError("wget didn't write a complete file") from error
980978
if iwidth < iheight:
981979
pwidth = int(
982980
self._image_resize[1]

0 commit comments

Comments
 (0)