@@ -176,7 +176,8 @@ class Cpu(sensors.Cpu):
176176 def percentage (interval : float ) -> float :
177177 cpu = get_hw_and_update (Hardware .HardwareType .Cpu )
178178 for sensor in cpu .Sensors :
179- if sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith ("CPU Total" ) and sensor .Value is not None :
179+ if sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith (
180+ "CPU Total" ) and sensor .Value is not None :
180181 return float (sensor .Value )
181182
182183 logger .error ("CPU load cannot be read" )
@@ -190,7 +191,8 @@ def frequency() -> float:
190191 for sensor in cpu .Sensors :
191192 if sensor .SensorType == Hardware .SensorType .Clock :
192193 # Keep only real core clocks, ignore effective core clocks
193- if "Core #" in str (sensor .Name ) and "Effective" not in str (sensor .Name ) and sensor .Value is not None :
194+ if "Core #" in str (sensor .Name ) and "Effective" not in str (
195+ sensor .Name ) and sensor .Value is not None :
194196 frequencies .append (float (sensor .Value ))
195197
196198 if frequencies :
@@ -213,19 +215,23 @@ def temperature() -> float:
213215 try :
214216 # By default, the average temperature of all CPU cores will be used
215217 for sensor in cpu .Sensors :
216- if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith ("Core Average" ) and sensor .Value is not None :
218+ if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith (
219+ "Core Average" ) and sensor .Value is not None :
217220 return float (sensor .Value )
218221 # If not available, the max core temperature will be used
219222 for sensor in cpu .Sensors :
220- if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith ("Core Max" ) and sensor .Value is not None :
223+ if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith (
224+ "Core Max" ) and sensor .Value is not None :
221225 return float (sensor .Value )
222226 # If not available, the CPU Package temperature (usually same as max core temperature) will be used
223227 for sensor in cpu .Sensors :
224- if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith ("CPU Package" ) and sensor .Value is not None :
228+ if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith (
229+ "CPU Package" ) and sensor .Value is not None :
225230 return float (sensor .Value )
226231 # Otherwise any sensor named "Core..." will be used
227232 for sensor in cpu .Sensors :
228- if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith ("Core" ) and sensor .Value is not None :
233+ if sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith (
234+ "Core" ) and sensor .Value is not None :
229235 return float (sensor .Value )
230236 except :
231237 pass
@@ -280,23 +286,28 @@ def stats(cls) -> Tuple[float, float, float, float]: # load (%) / used mem (%)
280286 temp = math .nan
281287
282288 for sensor in gpu_to_use .Sensors :
283- if sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith ("GPU Core" ) and sensor .Value is not None :
289+ if sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith (
290+ "GPU Core" ) and sensor .Value is not None :
284291 load = float (sensor .Value )
285292 elif sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith ("D3D 3D" ) and math .isnan (
286293 load ) and sensor .Value is not None :
287294 # Only use D3D usage if global "GPU Core" sensor is not available, because it is less
288295 # precise and does not cover the entire GPU: https://www.hwinfo.com/forum/threads/what-is-d3d-usage.759/
289296 load = float (sensor .Value )
290- elif sensor .SensorType == Hardware .SensorType .SmallData and str (sensor .Name ).startswith ("GPU Memory Used" ) and sensor .Value is not None :
297+ elif sensor .SensorType == Hardware .SensorType .SmallData and str (sensor .Name ).startswith (
298+ "GPU Memory Used" ) and sensor .Value is not None :
291299 used_mem = float (sensor .Value )
292300 elif sensor .SensorType == Hardware .SensorType .SmallData and str (sensor .Name ).startswith (
293- "D3D" ) and str (sensor .Name ).endswith ("Memory Used" ) and math .isnan (used_mem ) and sensor .Value is not None :
301+ "D3D" ) and str (sensor .Name ).endswith ("Memory Used" ) and math .isnan (
302+ used_mem ) and sensor .Value is not None :
294303 # Only use D3D memory usage if global "GPU Memory Used" sensor is not available, because it is less
295304 # precise and does not cover the entire GPU: https://www.hwinfo.com/forum/threads/what-is-d3d-usage.759/
296305 used_mem = float (sensor .Value )
297- elif sensor .SensorType == Hardware .SensorType .SmallData and str (sensor .Name ).startswith ("GPU Memory Total" ) and sensor .Value is not None :
306+ elif sensor .SensorType == Hardware .SensorType .SmallData and str (sensor .Name ).startswith (
307+ "GPU Memory Total" ) and sensor .Value is not None :
298308 total_mem = float (sensor .Value )
299- elif sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith ("GPU Core" ) and sensor .Value is not None :
309+ elif sensor .SensorType == Hardware .SensorType .Temperature and str (sensor .Name ).startswith (
310+ "GPU Core" ) and sensor .Value is not None :
300311 temp = float (sensor .Value )
301312
302313 return load , (used_mem / total_mem * 100.0 ), used_mem , temp
@@ -310,7 +321,8 @@ def fps(cls) -> int:
310321
311322 try :
312323 for sensor in gpu_to_use .Sensors :
313- if sensor .SensorType == Hardware .SensorType .Factor and "FPS" in str (sensor .Name ) and sensor .Value is not None :
324+ if sensor .SensorType == Hardware .SensorType .Factor and "FPS" in str (
325+ sensor .Name ) and sensor .Value is not None :
314326 # If a reading returns a value <= 0, returns old value instead
315327 if int (sensor .Value ) > 0 :
316328 cls .prev_fps = int (sensor .Value )
@@ -375,14 +387,17 @@ def swap_percent() -> float:
375387
376388 # Get virtual / physical memory stats
377389 for sensor in memory .Sensors :
378- if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith ("Virtual Memory Used" ) and sensor .Value is not None :
390+ if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
391+ "Virtual Memory Used" ) and sensor .Value is not None :
379392 virtual_mem_used = int (sensor .Value )
380- elif sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith ("Memory Used" ) and sensor .Value is not None :
393+ elif sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
394+ "Memory Used" ) and sensor .Value is not None :
381395 mem_used = int (sensor .Value )
382396 elif sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
383397 "Virtual Memory Available" ) and sensor .Value is not None :
384398 virtual_mem_available = int (sensor .Value )
385- elif sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith ("Memory Available" ) and sensor .Value is not None :
399+ elif sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
400+ "Memory Available" ) and sensor .Value is not None :
386401 mem_available = int (sensor .Value )
387402
388403 # Compute swap stats from virtual / physical memory stats
@@ -401,7 +416,8 @@ def swap_percent() -> float:
401416 def virtual_percent () -> float :
402417 memory = get_hw_and_update (Hardware .HardwareType .Memory )
403418 for sensor in memory .Sensors :
404- if sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith ("Memory" ) and sensor .Value is not None :
419+ if sensor .SensorType == Hardware .SensorType .Load and str (sensor .Name ).startswith (
420+ "Memory" ) and sensor .Value is not None :
405421 return float (sensor .Value )
406422
407423 return math .nan
@@ -410,7 +426,8 @@ def virtual_percent() -> float:
410426 def virtual_used () -> int : # In bytes
411427 memory = get_hw_and_update (Hardware .HardwareType .Memory )
412428 for sensor in memory .Sensors :
413- if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith ("Memory Used" ) and sensor .Value is not None :
429+ if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
430+ "Memory Used" ) and sensor .Value is not None :
414431 return int (sensor .Value * 1000000000.0 )
415432
416433 return 0
@@ -419,7 +436,8 @@ def virtual_used() -> int: # In bytes
419436 def virtual_free () -> int : # In bytes
420437 memory = get_hw_and_update (Hardware .HardwareType .Memory )
421438 for sensor in memory .Sensors :
422- if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith ("Memory Available" ) and sensor .Value is not None :
439+ if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
440+ "Memory Available" ) and sensor .Value is not None :
423441 return int (sensor .Value * 1000000000.0 )
424442
425443 return 0
@@ -455,7 +473,8 @@ def stats(if_name, interval) -> Tuple[
455473 net_if = get_net_interface_and_update (if_name )
456474 if net_if is not None :
457475 for sensor in net_if .Sensors :
458- if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith ("Data Uploaded" ) and sensor .Value is not None :
476+ if sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
477+ "Data Uploaded" ) and sensor .Value is not None :
459478 uploaded = int (sensor .Value * 1000000000.0 )
460479 elif sensor .SensorType == Hardware .SensorType .Data and str (sensor .Name ).startswith (
461480 "Data Downloaded" ) and sensor .Value is not None :
0 commit comments