-
-
Save chand1012/1ae6f3703089526b3ac9148e8f79dccb to your computer and use it in GitHub Desktop.
| 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) |
i got to have this error
$ python -u "d:\kshitij\python\overlay\cpu_temp.py"
Traceback (most recent call last):
File "D:\programs\python\python3.10\lib\site-packages\wmi.py", line 1340, in connect
obj = GetObject(moniker)
File "D:\programs\python\python3.10\lib\site-packages\win32com\client_init_.py", line 85, in GetObject
return Moniker(Pathname, clsctx)
File "D:\programs\python\python3.10\lib\site-packages\win32com\client_init_.py", line 102, in Moniker
moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname)
pywintypes.com_error: (-2147217394, 'OLE error 0x8004100e', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\kshitij\python\overlay\cpu_temp.py", line 11, in
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
File "D:\programs\python\python3.10\lib\site-packages\wmi.py", line 1354, in connect
handle_com_error()
File "D:\programs\python\python3.10\lib\site-packages\wmi.py", line 258, in handle_com_error
raise klass(com_error=err)
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217394, 'OLE error 0x8004100e', None, None)>
i got the same error:
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217394, 'OLE error 0x8004100e', None, None)>
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)>
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217394, 'OLE error 0x8004100e', None, None)> same
memory usage rises all the time.