Reputation:
so im using WMI and Open Hardware Monitor to get my CPU and GPU temperatures.
the code
import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
for sensor in temperature_infos:
if sensor.SensorType==u'Temperature':
print(sensor.Name)
print(sensor.Value)
how would i make it so it waits for sensor.Name
and sensor.Value
and then prints it all at once, instead of printing it as it gets the data?
Upvotes: 1
Views: 139
Reputation: 34086
Try:
import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
d = dict() ## Create an empty dictionary
for sensor in temperature_infos:
if sensor.SensorType==u'Temperature':
#print(sensor.Name)
#print(sensor.Value)
d[sensor.Name] = sensor.Value
print(d) # Print the dictionary when the loop is over
Upvotes: 1