Skip to content

Commit

Permalink
Handle errors regarding temperature threshold (#89)
Browse files Browse the repository at this point in the history
If no custom threshold is set we need something to compare to.
If the custom threshold is not a valid value we need to catch ValueError.
If the custom threshold is lower than zero we need to set some value, too.
For all these cases, we use self.THRESHOLD_TEMP as value for temp_thresh.

This fixes issue #87.
  • Loading branch information
Michael Kesper authored and amanusk committed Oct 15, 2018
1 parent c934e0c commit 265840b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions s_tui/Sources/TemperatureSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ def __init__(self, custom_temp=None, temp_thresh=None):

# Set temperature threshold if a custom one is set
if temp_thresh is not None:
if int(temp_thresh) > 0:
self.temp_thresh = int(temp_thresh)
logging.debug("Updated custom threshold to " +
str(self.temp_thresh))
try:
if int(temp_thresh) > 0:
self.temp_thresh = int(temp_thresh)
logging.debug("Updated custom threshold to " +
str(self.temp_thresh))
else:
self.temp_thresh = self.THRESHOLD_TEMP
except ValueError:
self.temp_thresh = self.THRESHOLD_TEMP
else:
self.temp_thresh = self.THRESHOLD_TEMP
self.update()
logging.debug("Update is updated to " + str(self.update))

Expand Down

0 comments on commit 265840b

Please sign in to comment.