temp.py: Fixed bug related to dynamic colors (#672)
When a custom alert_temp was given, for any temperature value above alert_temp the module generated an "IndexError: string index out of range" error.
This commit is contained in:
parent
625d6a0b9d
commit
55f8812bc9
@ -189,7 +189,10 @@ class Temperature(IntervalModule, ColorRangeModule):
|
||||
temp = float(f.read().strip()) / 1000
|
||||
|
||||
if self.dynamic_color:
|
||||
color = self.colors[int(self.percentage(int(temp), self.alert_temp))]
|
||||
perc = int(self.percentage(int(temp), self.alert_temp))
|
||||
if (perc > 99):
|
||||
perc = 99
|
||||
color = self.colors[perc]
|
||||
else:
|
||||
color = self.color if temp < self.alert_temp else self.alert_color
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user