from telnetlib import Telnet
from typing import List, Dict, NamedTuple
+from logparse import formatting
from ..formatting import *
from ..util import readlog, resolve
from ..config import *
sensors.init()
- coretemps = []
- pkgtemp = 0
- systemp = 0
-
- systemp_data = Data("Sys")
- coretemp_data = Data("Cores")
- pkgtemp_data = Data("Processor")
+ systemp = Data("Sys", [])
+ coretemp = Data("Cores", [])
+ pkgtemp = Data("Processor", [])
try:
-
for chip in sensors.iter_detected_chips():
for feature in chip:
if "Core" in feature.label:
- coretemp_data.items.append([feature.label, feature.get_value()])
- logger.debug("Found core " + feature.label + " at temp " + str(feature.get_value()))
+ coretemp.items.append([feature.label, float(feature.get_value())])
+ continue
if "CPUTIN" in feature.label:
- pkgtem_data.items.append([feature.label, str(feature.get_value())])
- logger.debug("Found CPU package at temp" + str(feature.get_value()))
+ pkgtemp.items.append([feature.label, float(feature.get_value())])
+ continue
if "SYS" in feature.label:
- systemp_data.items.append([feature.label, str(feature.get_value())])
- logger.debug("Found sys input " + feature.label + " at temp " + str(feature.get_value()))
-
- for temp_data in [systemp_data, coretemp_data, pkgtemp_data]:
+ systemp.items.append([feature.label, float(feature.get_value())])
+ continue
+
+ logger.debug("Core data is {0}".format(str(coretemp.items)))
+ logger.debug("Sys data is {0}".format(str(systemp.items)))
+ logger.debug("Pkg data is {0}".format(str(pkgtemp.items)))
+ for temp_data in [systemp, coretemp, pkgtemp]:
+ logger.debug("Looking at temp data {0}".format(str(temp_data.items)))
if len(temp_data.items) > 1:
- avg = sum(feature[1] for feature in temp_data.items) / len(temp_data.items)
+ avg = float(sum(feature[1] for feature in temp_data.items)) / len(temp_data.items)
logger.debug("Avg temp for {0} is {1} {2}{3}".format(temp_data.subtitle, str(avg), DEG, CEL))
- temp_data.subtitle += " (avg {0}{1}{2}):".format(str(avg), DEG, CEL)
- temp_data.items = ["{0}: {1}{2}{3}".format(feature[0], feature[1], DEG, CEL) for feature in temp_data]
+ temp_data.subtitle += " (avg {0}{1}{2})".format(str(avg), DEG, CEL)
+ temp_data.items = ["{0}: {1}{2}{3}".format(feature[0], str(feature[1]), DEG, CEL) for feature in temp_data.items]
else:
- temp_data.items = temp_data[0][1] + DEG + CEL
+ temp_data.items = [str(temp_data.items[0][1]) + DEG + CEL]
section.append_data(temp_data)
finally: