Don't allow exception to stop updaters

This commit is contained in:
Mike Cifelli 2022-12-28 18:37:32 -05:00
parent bbc7e505ae
commit 460be567c9
3 changed files with 7 additions and 30 deletions

View File

@ -57,37 +57,20 @@ class CharacterDisplay:
self.unicorn.show() self.unicorn.show()
def displayTimeDots(self, x, y, color): def displayTimeDots(self, x, y, color):
self.setPixel(x, y, colors.BLACK)
self.setPixel(x, y-1, color) self.setPixel(x, y-1, color)
self.setPixel(x, y-2, colors.BLACK)
self.setPixel(x, y-3, color) self.setPixel(x, y-3, color)
self.setPixel(x, y-4, colors.BLACK)
self.unicorn.show() self.unicorn.show()
def displayDegree(self, x, y, color): def displayDegree(self, x, y, color):
self.setPixel(x, y, color) self.setPixel(x, y, color)
self.setPixel(x, y-1, 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, color)
self.setPixel(x+1, y-1, 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() self.unicorn.show()
def displayNegative(self, x, y, color): 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, y-2, color)
self.setPixel(x+1, 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() self.unicorn.show()
def displaySquare(self, x, y, outlineColor, fillColor): 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-2, outlineColor)
self.rightSide(x+1, y-3, outlineColor) self.rightSide(x+1, y-3, outlineColor)
self.leftSide(x+1, y-1, fillColor) self.setPixel(x+1, y-1, fillColor)
self.leftSide(x+1, y-2, fillColor) self.setPixel(x+1, y-2, fillColor)
self.leftSide(x+2, y-1, fillColor) self.setPixel(x+2, y-1, fillColor)
self.leftSide(x+2, y-2, fillColor) self.setPixel(x+2, y-2, fillColor)
self.unicorn.show() self.unicorn.show()
def displayZero(self, x, y, color): def displayZero(self, x, y, color):

View File

@ -18,12 +18,9 @@ class GarageUpdater:
try: try:
state = self.getGarageState() state = self.getGarageState()
self.persistGarageState(state) self.persistGarageState(state)
except requests.exceptions.ConnectionError as e: except Exception as e:
print(e, flush=True) print(e, flush=True)
self.persistGarageState('{"error": "connection"}') self.persistGarageState('{"error": "exception"}')
except requests.exceptions.Timeout as e:
print(e, flush=True)
self.persistGarageState('{"error": "timeout"}')
def clearGarageState(self): def clearGarageState(self):
self.persistGarageState('{"error": "halted"}') self.persistGarageState('{"error": "halted"}')

View File

@ -25,10 +25,7 @@ class WeatherUpdater:
try: try:
temperature = round(self.getTemperature()) temperature = round(self.getTemperature())
self.persistTemperature(temperature) self.persistTemperature(temperature)
except requests.exceptions.ConnectionError as e: except Exception as e:
print(e, flush=True)
self.persistTemperature('error')
except requests.exceptions.Timeout as e:
print(e, flush=True) print(e, flush=True)
self.persistTemperature('error') self.persistTemperature('error')