temp.py: Raise an Exception if no sensors detected. (#627)

Provides a better error message for cases such as #626.
This commit is contained in:
Facetoe 2017-11-22 19:21:48 +08:00 committed by GitHub
parent 8682fa232a
commit 48e5074412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,6 +203,9 @@ class Temperature(IntervalModule, ColorRangeModule):
"""
data = dict()
found_sensors = get_sensors()
if len(found_sensors) == 0:
raise Exception("No sensors detected! "
"Ensure lm-sensors is installed and check the output of the `sensors` command.")
for sensor in found_sensors:
data[sensor.name] = self.format_sensor(sensor)
data["{}_bar".format(sensor.name)] = self.format_sensor_bar(sensor)