HardwareMonitor 1.2.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- HardwareMonitor/Hardware/CPU/__init__.py +3 -0
- HardwareMonitor/Hardware/CPU/__init__.pyi +64 -0
- HardwareMonitor/Hardware/Controller/AeroCool/__init__.py +3 -0
- HardwareMonitor/Hardware/Controller/AeroCool/__init__.pyi +9 -0
- HardwareMonitor/Hardware/Controller/AquaComputer/__init__.py +3 -0
- HardwareMonitor/Hardware/Controller/AquaComputer/__init__.pyi +9 -0
- HardwareMonitor/Hardware/Controller/MSI/__init__.py +3 -0
- HardwareMonitor/Hardware/Controller/MSI/__init__.pyi +91 -0
- HardwareMonitor/Hardware/Controller/__init__.py +0 -0
- HardwareMonitor/Hardware/Gpu/__init__.py +3 -0
- HardwareMonitor/Hardware/Gpu/__init__.pyi +6 -0
- HardwareMonitor/Hardware/Motherboard/Lpc/EC/__init__.py +3 -0
- HardwareMonitor/Hardware/Motherboard/Lpc/EC/__init__.pyi +83 -0
- HardwareMonitor/Hardware/Motherboard/Lpc/__init__.py +0 -0
- HardwareMonitor/Hardware/Motherboard/__init__.py +3 -0
- HardwareMonitor/Hardware/Motherboard/__init__.pyi +420 -0
- HardwareMonitor/Hardware/PowerMonitor/__init__.py +3 -0
- HardwareMonitor/Hardware/PowerMonitor/__init__.pyi +26 -0
- HardwareMonitor/Hardware/Psu/Corsair/__init__.py +3 -0
- HardwareMonitor/Hardware/Psu/Corsair/__init__.pyi +9 -0
- HardwareMonitor/Hardware/Psu/Msi/__init__.py +3 -0
- HardwareMonitor/Hardware/Psu/Msi/__init__.pyi +9 -0
- HardwareMonitor/Hardware/Psu/__init__.py +3 -0
- HardwareMonitor/Hardware/Psu/__init__.pyi +7 -0
- HardwareMonitor/Hardware/Storage/__init__.py +3 -0
- HardwareMonitor/Hardware/Storage/__init__.pyi +49 -0
- HardwareMonitor/Hardware/__init__.py +3 -0
- HardwareMonitor/Hardware/__init__.pyi +968 -0
- HardwareMonitor/Interop/PowerMonitor/__init__.py +3 -0
- HardwareMonitor/Interop/PowerMonitor/__init__.pyi +251 -0
- HardwareMonitor/Interop/__init__.py +3 -0
- HardwareMonitor/PawnIo/__init__.py +3 -0
- HardwareMonitor/PawnIo/__init__.pyi +109 -0
- HardwareMonitor/Software/__init__.py +3 -0
- HardwareMonitor/Software/__init__.pyi +9 -0
- HardwareMonitor/Util.py +200 -0
- HardwareMonitor/__init__.py +51 -0
- HardwareMonitor/_util/types.py +0 -0
- HardwareMonitor/_util/types.pyi +239 -0
- HardwareMonitor/lib/BlackSharp.Core.dll +0 -0
- HardwareMonitor/lib/DiskInfoToolkit.dll +0 -0
- HardwareMonitor/lib/HidSharp.dll +0 -0
- HardwareMonitor/lib/LICENSE +373 -0
- HardwareMonitor/lib/LibreHardwareMonitorLib.dll +0 -0
- HardwareMonitor/lib/RAMSPDToolkit-NDD.dll +0 -0
- HardwareMonitor/lib/System.Memory.dll +0 -0
- HardwareMonitor/lib/System.Numerics.Vectors.dll +0 -0
- HardwareMonitor/lib/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- HardwareMonitor/lib/__init__.py +0 -0
- hardwaremonitor-1.2.0.dist-info/METADATA +198 -0
- hardwaremonitor-1.2.0.dist-info/RECORD +54 -0
- hardwaremonitor-1.2.0.dist-info/WHEEL +5 -0
- hardwaremonitor-1.2.0.dist-info/licenses/LICENSE +29 -0
- hardwaremonitor-1.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
from HardwareMonitor._util.types import DateTime, UInt16, UInt32
|
|
2
|
+
from typing import List, Set, overload
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AVG(int):
|
|
6
|
+
AVG_22MS = 0
|
|
7
|
+
AVG_44MS = 1
|
|
8
|
+
AVG_89MS = 2
|
|
9
|
+
AVG_177MS = 3
|
|
10
|
+
AVG_354MS = 4
|
|
11
|
+
AVG_709MS = 5
|
|
12
|
+
AVG_1417MS = 6
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class CurrentScale(int):
|
|
16
|
+
CurrentScale5A = 0
|
|
17
|
+
CurrentScale10A = 1
|
|
18
|
+
CurrentScale15A = 2
|
|
19
|
+
CurrentScale20A = 3
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DeviceConfigStructV1:
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DeviceConfigStructV2:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DeviceConfigStructV3:
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class DeviceData:
|
|
35
|
+
def __init__(self): ...
|
|
36
|
+
@property
|
|
37
|
+
def Connected(self) -> bool: ...
|
|
38
|
+
@property
|
|
39
|
+
def ExternalTemp1C(self) -> float: ...
|
|
40
|
+
@property
|
|
41
|
+
def ExternalTemp2C(self) -> float: ...
|
|
42
|
+
@property
|
|
43
|
+
def FaultLog(self) -> UInt16: ...
|
|
44
|
+
@property
|
|
45
|
+
def FaultStatus(self) -> UInt16: ...
|
|
46
|
+
@property
|
|
47
|
+
def FirmwareVersion(self) -> str: ...
|
|
48
|
+
@property
|
|
49
|
+
def HardwareRevision(self) -> str: ...
|
|
50
|
+
@property
|
|
51
|
+
def OnboardTempInC(self) -> float: ...
|
|
52
|
+
@property
|
|
53
|
+
def OnboardTempOutC(self) -> float: ...
|
|
54
|
+
@property
|
|
55
|
+
def PinCurrent(self) -> Set[float]: ...
|
|
56
|
+
@property
|
|
57
|
+
def PinVoltage(self) -> Set[float]: ...
|
|
58
|
+
@property
|
|
59
|
+
def PsuCapabilityW(self) -> int: ...
|
|
60
|
+
@property
|
|
61
|
+
def SumCurrentA(self) -> float: ...
|
|
62
|
+
@property
|
|
63
|
+
def SumPowerW(self) -> float: ...
|
|
64
|
+
@property
|
|
65
|
+
def Timestamp(self) -> DateTime: ...
|
|
66
|
+
@Connected.setter
|
|
67
|
+
def Connected(self, value: bool) -> None: ...
|
|
68
|
+
@ExternalTemp1C.setter
|
|
69
|
+
def ExternalTemp1C(self, value: float) -> None: ...
|
|
70
|
+
@ExternalTemp2C.setter
|
|
71
|
+
def ExternalTemp2C(self, value: float) -> None: ...
|
|
72
|
+
@FaultLog.setter
|
|
73
|
+
def FaultLog(self, value: UInt16) -> None: ...
|
|
74
|
+
@FaultStatus.setter
|
|
75
|
+
def FaultStatus(self, value: UInt16) -> None: ...
|
|
76
|
+
@FirmwareVersion.setter
|
|
77
|
+
def FirmwareVersion(self, value: str) -> None: ...
|
|
78
|
+
@HardwareRevision.setter
|
|
79
|
+
def HardwareRevision(self, value: str) -> None: ...
|
|
80
|
+
@OnboardTempInC.setter
|
|
81
|
+
def OnboardTempInC(self, value: float) -> None: ...
|
|
82
|
+
@OnboardTempOutC.setter
|
|
83
|
+
def OnboardTempOutC(self, value: float) -> None: ...
|
|
84
|
+
@PinCurrent.setter
|
|
85
|
+
def PinCurrent(self, value: Set[float]) -> None: ...
|
|
86
|
+
@PinVoltage.setter
|
|
87
|
+
def PinVoltage(self, value: Set[float]) -> None: ...
|
|
88
|
+
@PsuCapabilityW.setter
|
|
89
|
+
def PsuCapabilityW(self, value: int) -> None: ...
|
|
90
|
+
@Timestamp.setter
|
|
91
|
+
def Timestamp(self, value: DateTime) -> None: ...
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class DISPLAY_INVERSION(int):
|
|
95
|
+
DISPLAY_INVERSION_OFF = 0
|
|
96
|
+
DISPLAY_INVERSION_ON = 1
|
|
97
|
+
DISPLAY_INVERSION_NUM = 2
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class DisplayRotation(int):
|
|
101
|
+
DisplayRotation0 = 0
|
|
102
|
+
DisplayRotation180 = 1
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class FanConfigStruct:
|
|
106
|
+
pass
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class FanMode(int):
|
|
110
|
+
FanModeCurve = 0
|
|
111
|
+
FanModeFixed = 1
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class HpwrCapability(int):
|
|
115
|
+
PSU_CAP_600W = 0
|
|
116
|
+
PSU_CAP_450W = 1
|
|
117
|
+
PSU_CAP_300W = 2
|
|
118
|
+
PSU_CAP_150W = 3
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class NVM_CMD(int):
|
|
122
|
+
NVM_CMD_NONE = 0
|
|
123
|
+
NVM_CMD_LOAD = 1
|
|
124
|
+
NVM_CMD_STORE = 2
|
|
125
|
+
NVM_CMD_RESET = 3
|
|
126
|
+
NVM_CMD_LOAD_CAL = 4
|
|
127
|
+
NVM_CMD_STORE_CAL = 5
|
|
128
|
+
NVM_CMD_LOAD_CAL_FACTORY = 6
|
|
129
|
+
NVM_CMD_STORE_CAL_FACTORY = 7
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class PowerScale(int):
|
|
133
|
+
PowerScaleAuto = 0
|
|
134
|
+
PowerScale300W = 1
|
|
135
|
+
PowerScale600W = 2
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class PowerSensor:
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class Screen(int):
|
|
143
|
+
ScreenMain = 0
|
|
144
|
+
ScreenSimple = 1
|
|
145
|
+
ScreenCurrent = 2
|
|
146
|
+
ScreenTemp = 3
|
|
147
|
+
ScreenStatus = 4
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class SCREEN_CMD(int):
|
|
151
|
+
SCREEN_GOTO_MAIN = 224
|
|
152
|
+
SCREEN_GOTO_SIMPLE = 225
|
|
153
|
+
SCREEN_GOTO_CURRENT = 226
|
|
154
|
+
SCREEN_GOTO_TEMP = 227
|
|
155
|
+
SCREEN_GOTO_STATUS = 228
|
|
156
|
+
SCREEN_GOTO_SAME = 239
|
|
157
|
+
SCREEN_PAUSE_UPDATES = 240
|
|
158
|
+
SCREEN_RESUME_UPDATES = 241
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class SensorStruct:
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class SensorTs(int):
|
|
166
|
+
SENSOR_TS_IN = 0
|
|
167
|
+
SENSOR_TS_OUT = 1
|
|
168
|
+
SENSOR_TS3 = 2
|
|
169
|
+
SENSOR_TS4 = 3
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class Stm32PortFinder:
|
|
173
|
+
@overload
|
|
174
|
+
def FindMatchingComPorts(vid: UInt32, pid: UInt32) -> List: ...
|
|
175
|
+
@overload
|
|
176
|
+
def FindMatchingComPorts(vid: str, pid: str) -> List: ...
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class StructureConversion:
|
|
180
|
+
def ConvertConfigV1ToV2(configV1: DeviceConfigStructV1) -> DeviceConfigStructV2: ...
|
|
181
|
+
def ConvertConfigV1ToV3(configV1: DeviceConfigStructV1) -> DeviceConfigStructV3: ...
|
|
182
|
+
def ConvertConfigV2ToV1(configV2: DeviceConfigStructV2) -> DeviceConfigStructV1: ...
|
|
183
|
+
def ConvertConfigV2ToV3(configV2: DeviceConfigStructV2) -> DeviceConfigStructV3: ...
|
|
184
|
+
def ConvertConfigV3ToV1(configV3: DeviceConfigStructV3) -> DeviceConfigStructV1: ...
|
|
185
|
+
def ConvertConfigV3ToV2(configV3: DeviceConfigStructV3) -> DeviceConfigStructV2: ...
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class TempSource(int):
|
|
189
|
+
TempSourceTsIn = 0
|
|
190
|
+
TempSourceTsOut = 1
|
|
191
|
+
TempSourceTs1 = 2
|
|
192
|
+
TempSourceTs2 = 3
|
|
193
|
+
TempSourceTmax = 4
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class Theme(int):
|
|
197
|
+
ThemeTg1 = 0
|
|
198
|
+
ThemeTg2 = 1
|
|
199
|
+
ThemeTg3 = 2
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class THEME_BACKGROUND(int):
|
|
203
|
+
ThermalGrizzlyOrange = 1
|
|
204
|
+
ThermalGrizzlyDark = 2
|
|
205
|
+
Disabled = 255
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class THEME_FAN(int):
|
|
209
|
+
ThermalGrizzlyOrange = 100
|
|
210
|
+
ThermalGrizzlyDark = 117
|
|
211
|
+
ThermalGrizzlyBlackWhite = 152
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class TimeoutMode(int):
|
|
215
|
+
TimeoutModeStatic = 0
|
|
216
|
+
TimeoutModeCycle = 1
|
|
217
|
+
TimeoutModeSleep = 2
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class UiConfigStructV1:
|
|
221
|
+
pass
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class UiConfigStructV2:
|
|
225
|
+
pass
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
class UsbCmd(int):
|
|
229
|
+
CMD_WELCOME = 0
|
|
230
|
+
CMD_READ_VENDOR_DATA = 1
|
|
231
|
+
CMD_READ_UID = 2
|
|
232
|
+
CMD_READ_DEVICE_DATA = 3
|
|
233
|
+
CMD_READ_SENSOR_VALUES = 4
|
|
234
|
+
CMD_READ_CONFIG = 5
|
|
235
|
+
CMD_WRITE_CONFIG = 6
|
|
236
|
+
CMD_READ_CALIBRATION = 7
|
|
237
|
+
CMD_WRITE_CALIBRATION = 8
|
|
238
|
+
CMD_SPI_FLASH_WRITE_PAGE = 9
|
|
239
|
+
CMD_SPI_FLASH_READ_PAGE = 10
|
|
240
|
+
CMD_SPI_FLASH_ERASE_SECTOR = 11
|
|
241
|
+
CMD_SCREEN_CHANGE = 12
|
|
242
|
+
CMD_READ_BUILD_INFO = 13
|
|
243
|
+
CMD_CLEAR_FAULTS = 14
|
|
244
|
+
CMD_RESET = 240
|
|
245
|
+
CMD_BOOTLOADER = 241
|
|
246
|
+
CMD_NVM_CONFIG = 242
|
|
247
|
+
CMD_NOP = 255
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class VendorDataStruct:
|
|
251
|
+
pass
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from HardwareMonitor._util.types import Byte, Int64, UInt32, UInt64
|
|
2
|
+
from typing import Set, Tuple, overload
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AmdFamily0F:
|
|
6
|
+
def __init__(self): ...
|
|
7
|
+
def Close(self) -> None: ...
|
|
8
|
+
def GetThermtrip(self, cpuIndex: int, coreIndex: UInt32) -> UInt32: ...
|
|
9
|
+
@overload
|
|
10
|
+
def ReadMsr(self, index: UInt32) -> Tuple[bool, UInt32, UInt32]: ...
|
|
11
|
+
@overload
|
|
12
|
+
def ReadMsr(self, index: UInt32, affinity: GroupAffinity) -> Tuple[bool, UInt32, UInt32]: ...
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AmdFamily10:
|
|
16
|
+
def __init__(self): ...
|
|
17
|
+
def Close(self) -> None: ...
|
|
18
|
+
def HaveCstateResidencyInfo(self) -> bool: ...
|
|
19
|
+
def MeasureTscMultiplier(self) -> Tuple[Int64, Int64]: ...
|
|
20
|
+
def ReadCstateResidency(self) -> Set[Byte]: ...
|
|
21
|
+
def ReadMiscCtl(self, cpu: int, offset: UInt32) -> UInt32: ...
|
|
22
|
+
@overload
|
|
23
|
+
def ReadMsr(self, index: UInt32) -> Tuple[bool, UInt32, UInt32]: ...
|
|
24
|
+
@overload
|
|
25
|
+
def ReadMsr(self, index: UInt32, affinity: GroupAffinity) -> Tuple[bool, UInt32, UInt32]: ...
|
|
26
|
+
def ReadSmu(self, offset: UInt32) -> UInt32: ...
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AmdFamily17:
|
|
30
|
+
def __init__(self): ...
|
|
31
|
+
def Close(self) -> None: ...
|
|
32
|
+
@overload
|
|
33
|
+
def ReadMsr(self, index: UInt32) -> Tuple[bool, UInt64]: ...
|
|
34
|
+
@overload
|
|
35
|
+
def ReadMsr(self, index: UInt32) -> Tuple[bool, UInt32, UInt32]: ...
|
|
36
|
+
def ReadSmn(self, offset: UInt32) -> UInt32: ...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class IntelMsr:
|
|
40
|
+
def __init__(self): ...
|
|
41
|
+
def Close(self) -> None: ...
|
|
42
|
+
@overload
|
|
43
|
+
def ReadMsr(self, index: UInt32) -> Tuple[bool, UInt64]: ...
|
|
44
|
+
@overload
|
|
45
|
+
def ReadMsr(self, index: UInt32) -> Tuple[bool, UInt32, UInt32]: ...
|
|
46
|
+
@overload
|
|
47
|
+
def ReadMsr(self, index: UInt32, affinity: GroupAffinity) -> Tuple[bool, UInt32, UInt32]: ...
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class IsaBridgeEc:
|
|
51
|
+
def __init__(self): ...
|
|
52
|
+
def Close(self) -> None: ...
|
|
53
|
+
def FindSuperIoMMIO(self) -> Tuple[bool, MMIOMapping, MMIOMapping]: ...
|
|
54
|
+
def GetOriginalState(self) -> Tuple[bool, MMIOState]: ...
|
|
55
|
+
def Map(self) -> bool: ...
|
|
56
|
+
def ReadMmio(self, superIoIndex: Int64, offset: Int64, size: Int64) -> Tuple[bool, Byte]: ...
|
|
57
|
+
def TryGetCurrentState(self) -> Tuple[bool, MMIOState]: ...
|
|
58
|
+
def TrySetState(self, state: MMIOState) -> bool: ...
|
|
59
|
+
def Unmap(self) -> bool: ...
|
|
60
|
+
def WriteMmio(self, superIoIndex: Int64, offset: Int64, size: Int64, value: Byte) -> bool: ...
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class LpcAcpiEc:
|
|
64
|
+
def __init__(self): ...
|
|
65
|
+
def Close(self) -> None: ...
|
|
66
|
+
def ReadPort(self, port: Byte) -> Byte: ...
|
|
67
|
+
def WritePort(self, port: Byte, value: Byte) -> None: ...
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class LpcCrOSEc:
|
|
71
|
+
def __init__(self): ...
|
|
72
|
+
def Close(self) -> None: ...
|
|
73
|
+
def EcCommand(self, version: int, command: int, outsize: int, insize: int, data: Set[Byte]) -> Set[Byte]: ...
|
|
74
|
+
def ReadMemmap(self, offset: Byte, bytes: Byte) -> Set[Byte]: ...
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class MMIOMapping:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class MMIOState(int):
|
|
82
|
+
MMIO_Disabled = 0
|
|
83
|
+
MMIO_Enabled2E = 1
|
|
84
|
+
MMIO_Enabled4E = 2
|
|
85
|
+
MMIO_EnabledBoth = 3
|
|
86
|
+
Unknown = -999
|
|
87
|
+
MMIO_Original = -1
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class PawnIo:
|
|
91
|
+
def Close(self) -> None: ...
|
|
92
|
+
def Execute(self, name: str, input: Set[Int64], outLength: int) -> Set[Int64]: ...
|
|
93
|
+
def ExecuteHr(self, name: str, inBuffer: Set[Int64], inSize: UInt32, outBuffer: Set[Int64], outSize: UInt32) -> Tuple[int, UInt32]: ...
|
|
94
|
+
@property
|
|
95
|
+
def IsInstalled() -> bool: ...
|
|
96
|
+
@property
|
|
97
|
+
def IsLoaded(self) -> bool: ...
|
|
98
|
+
@property
|
|
99
|
+
def Version() -> Version: ...
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class RyzenSmu:
|
|
103
|
+
def __init__(self): ...
|
|
104
|
+
def Close(self) -> None: ...
|
|
105
|
+
def GetCodeName(self) -> Int64: ...
|
|
106
|
+
def GetSmuVersion(self) -> UInt32: ...
|
|
107
|
+
def ReadPmTable(self, size: int) -> Set[Int64]: ...
|
|
108
|
+
def ResolvePmTable(self) -> Tuple[UInt32, UInt32]: ...
|
|
109
|
+
def UpdatePmTable(self) -> None: ...
|
HardwareMonitor/Util.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Dict, Iterable, List, TypeAlias, cast
|
|
5
|
+
|
|
6
|
+
from System.Collections.Generic import IDictionary, IList
|
|
7
|
+
|
|
8
|
+
import HardwareMonitor
|
|
9
|
+
from HardwareMonitor._util.types import Nullable
|
|
10
|
+
from HardwareMonitor.Hardware import Computer, Hardware, HardwareType, IParameter, ISensor, IVisitor, SensorType
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger("PyHardwareMonitor")
|
|
13
|
+
|
|
14
|
+
# ------------------------------------------------------------------------------
|
|
15
|
+
def _get_name_to_type(obj):
|
|
16
|
+
def object_getattr(attr):
|
|
17
|
+
try: return getattr(obj, attr)
|
|
18
|
+
except: pass
|
|
19
|
+
result = {}
|
|
20
|
+
for (a, v) in zip(dir(obj), map(object_getattr, dir(obj))):
|
|
21
|
+
if type(v) in (int, obj):
|
|
22
|
+
result[v] = result[int(v)] = a
|
|
23
|
+
return result
|
|
24
|
+
|
|
25
|
+
HardwareTypeString: Dict[HardwareType|int, str] = _get_name_to_type(HardwareType)
|
|
26
|
+
SensorTypeString: Dict[SensorType |int, str] = _get_name_to_type(SensorType)
|
|
27
|
+
|
|
28
|
+
SensorTypeUnitFormatter = {
|
|
29
|
+
SensorType.Voltage: "{:.3f} V",
|
|
30
|
+
SensorType.Current: "{:.3f} A",
|
|
31
|
+
SensorType.Clock: "{:.1f} MHz",
|
|
32
|
+
SensorType.Load: "{:.1f} %",
|
|
33
|
+
SensorType.Temperature: "{:.1f} °C",
|
|
34
|
+
SensorType.Fan: "{:.0f} RPM",
|
|
35
|
+
SensorType.Flow: "{:.1f} L/h",
|
|
36
|
+
SensorType.Control: "{:.1f} %",
|
|
37
|
+
SensorType.Level: "{:.1f} %",
|
|
38
|
+
SensorType.Power: "{:.1f} W",
|
|
39
|
+
SensorType.Data: "{:.1f} GB",
|
|
40
|
+
SensorType.SmallData: "{:.1f} MB",
|
|
41
|
+
SensorType.Factor: "{:.3f}",
|
|
42
|
+
SensorType.Frequency: "{:.1f} Hz",
|
|
43
|
+
SensorType.Throughput: "{:.1f} B/s",
|
|
44
|
+
SensorType.TimeSpan: "{}",
|
|
45
|
+
SensorType.Energy: "{:.0f} mWh",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
SensorType_t: TypeAlias = int
|
|
49
|
+
|
|
50
|
+
def SensorValueToString(value: float|Nullable, type: SensorType_t) -> str:
|
|
51
|
+
return SensorTypeUnitFormatter.get(type, "{}").format(isinstance(value, float) and value or 0)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def GroupSensorsByType(sensors: Iterable[ISensor]) -> List[List[ISensor]]:
|
|
55
|
+
groups = {}
|
|
56
|
+
for sensor in sensors:
|
|
57
|
+
group = groups[sensor.SensorType] = groups.get(sensor.SensorType, [])
|
|
58
|
+
group.append(sensor)
|
|
59
|
+
return list(groups.values())
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# ------------------------------------------------------------------------------
|
|
63
|
+
_generic_type_cache = {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def IsInstanceOfInterface(obj, interface):
|
|
67
|
+
if not hasattr(obj, "GetType"):
|
|
68
|
+
return False
|
|
69
|
+
try:
|
|
70
|
+
obj_type = obj.GetType()
|
|
71
|
+
if obj_type in _generic_type_cache:
|
|
72
|
+
return any(cmp == interface for cmp in _generic_type_cache[obj_type])
|
|
73
|
+
ifaces = list(i for i in obj.GetType().GetInterfaces() if i.IsGenericType)
|
|
74
|
+
cache = _generic_type_cache[obj_type] = set()
|
|
75
|
+
for iface in ifaces:
|
|
76
|
+
cache.add(iface.GetGenericTypeDefinition())
|
|
77
|
+
return any(cmp == interface for cmp in cache)
|
|
78
|
+
except:
|
|
79
|
+
pass
|
|
80
|
+
return False
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ------------------------------------------------------------------------------
|
|
84
|
+
_UPDATE_WARNING_CACHE = set()
|
|
85
|
+
def UpdateHardwareSafe(hardware: Hardware):
|
|
86
|
+
try:
|
|
87
|
+
hardware.Update()
|
|
88
|
+
except:
|
|
89
|
+
if hardware.Identifier not in _UPDATE_WARNING_CACHE:
|
|
90
|
+
logger.warning(f"Unable to update HardwareMonitor sensors for {hardware.Identifier} ('{hardware.Name}')")
|
|
91
|
+
_UPDATE_WARNING_CACHE.add(hardware.Identifier)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# ------------------------------------------------------------------------------
|
|
95
|
+
class UpdateVisitor(IVisitor):
|
|
96
|
+
__namespace__ = "HardwareMonitor.Util"
|
|
97
|
+
def __init__(self, time_window=1.0):
|
|
98
|
+
super().__init__()
|
|
99
|
+
self.time_window = time_window
|
|
100
|
+
|
|
101
|
+
def VisitComputer(self, computer: Computer):
|
|
102
|
+
computer.Traverse(self)
|
|
103
|
+
|
|
104
|
+
def VisitHardware(self, hardware: Hardware):
|
|
105
|
+
UpdateHardwareSafe(hardware)
|
|
106
|
+
for subHardware in hardware.SubHardware:
|
|
107
|
+
UpdateHardwareSafe(cast(Hardware, subHardware))
|
|
108
|
+
|
|
109
|
+
def VisitParameter(self, parameter: IParameter):
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
def VisitSensor(self, sensor: ISensor):
|
|
113
|
+
sensor.ValuesTimeWindow = self.time_window # type: ignore
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# ------------------------------------------------------------------------------
|
|
117
|
+
class PyComputer(Computer):
|
|
118
|
+
def __init__(self, time_window=1.0, **settings):
|
|
119
|
+
def attr_filter(attr):
|
|
120
|
+
return attr.startswith("Is") and attr.endswith("Enabled")
|
|
121
|
+
|
|
122
|
+
super().__init__()
|
|
123
|
+
for attr in filter(attr_filter, dir(self)):
|
|
124
|
+
key = attr[2:-7].lower()
|
|
125
|
+
setattr(self, attr, bool(settings.get(key, settings.get("all", False))))
|
|
126
|
+
self._visitor = UpdateVisitor(time_window)
|
|
127
|
+
|
|
128
|
+
def Update(self):
|
|
129
|
+
self.Open()
|
|
130
|
+
self.Accept(self._visitor)
|
|
131
|
+
return self
|
|
132
|
+
|
|
133
|
+
def __enter__(self):
|
|
134
|
+
self.Open()
|
|
135
|
+
self.Accept(self._visitor)
|
|
136
|
+
return self
|
|
137
|
+
|
|
138
|
+
def __exit__(self, *args):
|
|
139
|
+
self.Close()
|
|
140
|
+
|
|
141
|
+
def __del__(self):
|
|
142
|
+
try: self.Close()
|
|
143
|
+
except: pass
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# ------------------------------------------------------------------------------
|
|
147
|
+
def OpenComputer(**settings) -> PyComputer:
|
|
148
|
+
computer = PyComputer(**settings)
|
|
149
|
+
return computer.Update()
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# ------------------------------------------------------------------------------
|
|
153
|
+
def ToBuiltinTypes(obj, exclude=["Parameters", "Values"]):
|
|
154
|
+
def process_object(obj):
|
|
155
|
+
# Return 'primitive' python types as such
|
|
156
|
+
if type(obj) in (str, bytes, bool, int, float):
|
|
157
|
+
return obj
|
|
158
|
+
elif type(obj) in (list, tuple, set):
|
|
159
|
+
return list(map(process_object, obj))
|
|
160
|
+
elif type(obj) in (dict,):
|
|
161
|
+
return dict((k, process_object(v)) for k,v in obj.items())
|
|
162
|
+
# Handle .NET objects
|
|
163
|
+
if hasattr(obj, "GetType"):
|
|
164
|
+
# Return enums as the string representation of the value
|
|
165
|
+
if obj.GetType().IsEnum:
|
|
166
|
+
return obj.ToString()
|
|
167
|
+
# Prevent recursion within HardwareMonitor objects
|
|
168
|
+
if obj in visited:
|
|
169
|
+
return None
|
|
170
|
+
visited.add(obj)
|
|
171
|
+
# Convert lists and dictionaries to python objects
|
|
172
|
+
if obj.GetType().IsArray or IsInstanceOfInterface(obj, IList):
|
|
173
|
+
return list(map(process_object, obj))
|
|
174
|
+
if IsInstanceOfInterface(obj, IDictionary):
|
|
175
|
+
return dict((k, process_object(obj.get_Item(k))) for k in list(obj))
|
|
176
|
+
# Handle objects from the 'HardwareMonitor.Hardware' namespace
|
|
177
|
+
if obj.__class__.__module__.startswith(HardwareMonitor.ASSEMBLY_NAME):
|
|
178
|
+
cls_name = obj.__class__.__name__
|
|
179
|
+
if cls_name[:2].isupper() and cls_name[0] == "I":
|
|
180
|
+
cls_name = cls_name[1:]
|
|
181
|
+
obj_dict = {}
|
|
182
|
+
# Iterate over all "public" members of the object
|
|
183
|
+
for attr in [a for a in dir(obj) if not a.startswith("_")]:
|
|
184
|
+
if attr in exclude or attr.startswith("IsDefault"):
|
|
185
|
+
continue
|
|
186
|
+
val = getattr(obj, attr)
|
|
187
|
+
val_reduced = process_object(val)
|
|
188
|
+
if val_reduced is None or val_reduced == [None]:
|
|
189
|
+
continue
|
|
190
|
+
elif val_reduced or type(val_reduced) is not dict:
|
|
191
|
+
obj_dict[attr] = val_reduced
|
|
192
|
+
if not obj_dict:
|
|
193
|
+
return None
|
|
194
|
+
# Add the class name to allow for easy filtering
|
|
195
|
+
result = {"Type": cls_name}
|
|
196
|
+
result.update(obj_dict)
|
|
197
|
+
return result
|
|
198
|
+
return None
|
|
199
|
+
visited = set()
|
|
200
|
+
return process_object(obj)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
import sys
|
|
3
|
+
import clr
|
|
4
|
+
import ctypes
|
|
5
|
+
import logging
|
|
6
|
+
import struct
|
|
7
|
+
import platform as _platform
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger("PyHardwareMonitor")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _checkForPawnIO():
|
|
15
|
+
"""
|
|
16
|
+
Detect if the PawnIO module is installed by searching for uninstall entry in the registry.
|
|
17
|
+
"""
|
|
18
|
+
import winreg
|
|
19
|
+
key_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PawnIO"
|
|
20
|
+
try:
|
|
21
|
+
access_flags = winreg.KEY_READ
|
|
22
|
+
if sys.maxsize < 2**32:
|
|
23
|
+
access_flags |= winreg.KEY_WOW64_64KEY
|
|
24
|
+
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path, 0, access_flags):
|
|
25
|
+
return True
|
|
26
|
+
except:
|
|
27
|
+
pass
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if not ctypes.windll.shell32.IsUserAnAdmin():
|
|
32
|
+
logger.warning("Admin privileges are required for 'HardwareMonitor' to work properly.")
|
|
33
|
+
|
|
34
|
+
if not _checkForPawnIO():
|
|
35
|
+
logger.warning("""PawnIO is not installed - Many sensor will not be available.
|
|
36
|
+
Please install manually through one of the following methods:
|
|
37
|
+
1) Run the terminal command 'winget install PawnIO'
|
|
38
|
+
2) Download and run 'https://github.com/namazso/PawnIO.Setup/releases/latest/download/PawnIO_setup.exe'
|
|
39
|
+
""")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
ASSEMBLY_NAME = "LibreHardwareMonitor"
|
|
43
|
+
|
|
44
|
+
_machine = _platform.machine().lower()
|
|
45
|
+
_arch = "ARM64" if _machine == "arm64" else ("x64" if struct.calcsize("P") == 8 else "x86")
|
|
46
|
+
_arch_lib = Path(__file__).parent.joinpath("lib", _arch)
|
|
47
|
+
_LIB_PATH = (_arch_lib if _arch_lib.is_dir() else Path(__file__).parent.joinpath("lib")).absolute()
|
|
48
|
+
sys.path.insert(0, str(_LIB_PATH))
|
|
49
|
+
__reference__ = clr.AddReference(str(_LIB_PATH / (ASSEMBLY_NAME + "Lib.dll")))
|
|
50
|
+
|
|
51
|
+
__import__(ASSEMBLY_NAME)
|
|
File without changes
|