From 18313432e0f422219239e47f7ac0079e1b272e23 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 15 Aug 2024 13:11:51 -0400 Subject: [PATCH] controller init: set _on_battery before switching profile Since 6ef5b58e , switch_profile expects self._on_battery to be set, but when it's called in Controller.initialize, it is called before we do self._on_battery = False , and will crash with AttributeError: 'Controller' object has no attribute '_on_battery' if the requested profile is not the currently active one. This fixes that by moving the call to switch_profile after self._on_battery is set. Signed-off-by: Adam Williamson --- tuned/ppd/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tuned/ppd/controller.py b/tuned/ppd/controller.py index 319590bc..4376c1e9 100644 --- a/tuned/ppd/controller.py +++ b/tuned/ppd/controller.py @@ -138,8 +138,8 @@ def initialize(self): self._config = PPDConfig(PPD_CONFIG_FILE) active_profile = self.active_profile() self._base_profile = active_profile if active_profile != UNKNOWN_PROFILE else self._config.default_profile - self.switch_profile(self._base_profile) self._on_battery = False + self.switch_profile(self._base_profile) if self._config.battery_detection: self.setup_battery_signaling()