Sprinkle on some try except

main
Dan Buch 6 years ago
parent 0354e8e441
commit dc5c99aa62
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7

@ -61,8 +61,11 @@ def _hwtemp(conf=THINKFAN_CONF):
for line in tfc_fp.readlines():
if not line.startswith('hwmon '):
continue
try:
with open(line.split(' ')[1].strip()) as temp_fp:
temps.append(float(temp_fp.read()))
except (OSError, IOError) as exc:
sys.stderr.write(str(exc) + '\n')
avg_temp = float(sum(temps)) / len(temps) / 1000.0
color = None
@ -102,6 +105,7 @@ def main(bits=_BITS):
loaded = json.loads(line)
for idx, name, func in bits:
try:
value, color = func()
if value is None:
continue
@ -111,6 +115,9 @@ def main(bits=_BITS):
record.update(dict(color=color))
loaded.insert(idx, record)
except Exception as exc:
sys.stderr.write(str(exc) + '\n')
sys.stderr.flush()
_print_line(prefix+json.dumps(loaded))

Loading…
Cancel
Save