1
0
Fork 0

ppd: Adjust the detection of 'performance-degraded'

In rare cases, 'lap-mode' and 'no-turbo' files may be
empty. Do not attempt to convert their content into
integers. Instead check if it's directly equal to "1"
(after stripping whitespace).
This commit is contained in:
Pavol Žáčik 2024-04-19 09:53:08 +02:00
parent b2ed1258c7
commit 31b21edc8a
No known key found for this signature in database
GPG key ID: B99527D5E6487A92

View file

@ -105,12 +105,10 @@ class Controller(exports.interfaces.ExportableInterface):
def _check_performance_degraded(self):
performance_degraded = PerformanceDegraded.NONE
if os.path.exists(NO_TURBO_PATH):
if int(self._cmd.read_file(NO_TURBO_PATH)) == 1:
performance_degraded = PerformanceDegraded.HIGH_OPERATING_TEMPERATURE
if os.path.exists(LAP_MODE_PATH):
if int(self._cmd.read_file(LAP_MODE_PATH)) == 1:
performance_degraded = PerformanceDegraded.LAP_DETECTED
if os.path.exists(NO_TURBO_PATH) and self._cmd.read_file(NO_TURBO_PATH).strip() == "1":
performance_degraded = PerformanceDegraded.HIGH_OPERATING_TEMPERATURE
if os.path.exists(LAP_MODE_PATH) and self._cmd.read_file(LAP_MODE_PATH).strip() == "1":
performance_degraded = PerformanceDegraded.LAP_DETECTED
if performance_degraded != self._performance_degraded:
log.info("Performance degraded: %s" % performance_degraded)
self._performance_degraded = performance_degraded