From 460be567c940eff467760215fc99ce3bac9812f6 Mon Sep 17 00:00:00 2001 From: Mike Cifelli <1836280-mike-cifelli@users.noreply.gitlab.com> Date: Wed, 28 Dec 2022 18:37:32 -0500 Subject: [PATCH] Don't allow exception to stop updaters --- character_display.py | 25 ++++--------------------- garage_updater.py | 7 ++----- weather_updater.py | 5 +---- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/character_display.py b/character_display.py index 5d50827..1f48296 100644 --- a/character_display.py +++ b/character_display.py @@ -57,37 +57,20 @@ class CharacterDisplay: self.unicorn.show() def displayTimeDots(self, x, y, color): - self.setPixel(x, y, colors.BLACK) self.setPixel(x, y-1, color) - self.setPixel(x, y-2, colors.BLACK) self.setPixel(x, y-3, color) - self.setPixel(x, y-4, colors.BLACK) self.unicorn.show() def displayDegree(self, x, y, color): self.setPixel(x, y, color) self.setPixel(x, y-1, color) - self.setPixel(x, y-2, colors.BLACK) - self.setPixel(x, y-3, colors.BLACK) - self.setPixel(x, y-4, colors.BLACK) self.setPixel(x+1, y, color) self.setPixel(x+1, y-1, color) - self.setPixel(x+1, y-2, colors.BLACK) - self.setPixel(x+1, y-3, colors.BLACK) - self.setPixel(x+1, y-4, colors.BLACK) self.unicorn.show() def displayNegative(self, x, y, color): - self.setPixel(x, y, colors.BLACK) - self.setPixel(x, y-1, colors.BLACK) - self.setPixel(x+1, y, colors.BLACK) - self.setPixel(x+1, y-1, colors.BLACK) self.setPixel(x, y-2, color) self.setPixel(x+1, y-2, color) - self.setPixel(x, y-3, colors.BLACK) - self.setPixel(x, y-4, colors.BLACK) - self.setPixel(x+1, y-3, colors.BLACK) - self.setPixel(x+1, y-4, colors.BLACK) self.unicorn.show() def displaySquare(self, x, y, outlineColor, fillColor): @@ -100,10 +83,10 @@ class CharacterDisplay: self.rightSide(x+1, y-2, outlineColor) self.rightSide(x+1, y-3, outlineColor) - self.leftSide(x+1, y-1, fillColor) - self.leftSide(x+1, y-2, fillColor) - self.leftSide(x+2, y-1, fillColor) - self.leftSide(x+2, y-2, fillColor) + self.setPixel(x+1, y-1, fillColor) + self.setPixel(x+1, y-2, fillColor) + self.setPixel(x+2, y-1, fillColor) + self.setPixel(x+2, y-2, fillColor) self.unicorn.show() def displayZero(self, x, y, color): diff --git a/garage_updater.py b/garage_updater.py index 5975c59..702f32f 100644 --- a/garage_updater.py +++ b/garage_updater.py @@ -18,12 +18,9 @@ class GarageUpdater: try: state = self.getGarageState() self.persistGarageState(state) - except requests.exceptions.ConnectionError as e: + except Exception as e: print(e, flush=True) - self.persistGarageState('{"error": "connection"}') - except requests.exceptions.Timeout as e: - print(e, flush=True) - self.persistGarageState('{"error": "timeout"}') + self.persistGarageState('{"error": "exception"}') def clearGarageState(self): self.persistGarageState('{"error": "halted"}') diff --git a/weather_updater.py b/weather_updater.py index 8edd402..c0da6fb 100644 --- a/weather_updater.py +++ b/weather_updater.py @@ -25,10 +25,7 @@ class WeatherUpdater: try: temperature = round(self.getTemperature()) self.persistTemperature(temperature) - except requests.exceptions.ConnectionError as e: - print(e, flush=True) - self.persistTemperature('error') - except requests.exceptions.Timeout as e: + except Exception as e: print(e, flush=True) self.persistTemperature('error')