|
|
|
@ -61,8 +61,11 @@ def _hwtemp(conf=THINKFAN_CONF):
|
|
|
|
|
for line in tfc_fp.readlines():
|
|
|
|
|
if not line.startswith('hwmon '):
|
|
|
|
|
continue
|
|
|
|
|
with open(line.split(' ')[1].strip()) as temp_fp:
|
|
|
|
|
temps.append(float(temp_fp.read()))
|
|
|
|
|
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,15 +105,19 @@ def main(bits=_BITS):
|
|
|
|
|
|
|
|
|
|
loaded = json.loads(line)
|
|
|
|
|
for idx, name, func in bits:
|
|
|
|
|
value, color = func()
|
|
|
|
|
if value is None:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
record = dict(full_text=str(value), name=name)
|
|
|
|
|
if color is not None:
|
|
|
|
|
record.update(dict(color=color))
|
|
|
|
|
|
|
|
|
|
loaded.insert(idx, record)
|
|
|
|
|
try:
|
|
|
|
|
value, color = func()
|
|
|
|
|
if value is None:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
record = dict(full_text=str(value), name=name)
|
|
|
|
|
if color is not None:
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
|
|