Created
February 20, 2018 18:19
-
-
Save chand1012/1ae6f3703089526b3ac9148e8f79dccb to your computer and use it in GitHub Desktop.
Get CPU and GPU temps from Windows with Python and OHM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wmi | |
def avg(value_list): | |
num = 0 | |
length = len(value_list) | |
for val in value_list: | |
num += val | |
return num/length | |
w = wmi.WMI(namespace="root\\OpenHardwareMonitor") | |
sensors = w.Sensor() | |
cpu_temps = [] | |
gpu_temp = 0 | |
for sensor in sensors: | |
if sensor.SensorType==u'Temperature' and not 'GPU' in sensor.Name: | |
cpu_temps += [float(sensor.Value)] | |
elif sensor.SensorType==u'Temperature' and 'GPU' in sensor.Name: | |
gpu_temp = sensor.Value | |
print "Avg CPU: {}".format(avg(cpu_temps)) | |
print "GPU: {}".format(gpu_temp) |
Same error <x_wmi: Unexpected COM Error (-2147217394, 'OLE error 0x8004100e', None, None)>
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217394, 'OLE error 0x8004100e', None, None)>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i got the same error:
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217394, 'OLE error 0x8004100e', None, None)>