From 16a28ffda03af7dcef3ed80ee461884ede2bb95d Mon Sep 17 00:00:00 2001 From: dw-0 Date: Mon, 25 Dec 2023 22:03:44 +0100 Subject: [PATCH] fix(Klipper/Moonraker): config files now always have a Path, are never None anymore Signed-off-by: Dominik Willner --- kiauh/modules/klipper/klipper.py | 8 +------- kiauh/modules/moonraker/moonraker.py | 10 ++-------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/kiauh/modules/klipper/klipper.py b/kiauh/modules/klipper/klipper.py index 71eb435..1f11fa2 100644 --- a/kiauh/modules/klipper/klipper.py +++ b/kiauh/modules/klipper/klipper.py @@ -30,7 +30,7 @@ class Klipper(BaseInstance): super().__init__(instance_type=self, suffix=suffix) self.klipper_dir: Path = KLIPPER_DIR self.env_dir: Path = KLIPPER_ENV_DIR - self._cfg_file = self._get_cfg() + self._cfg_file = self.cfg_dir.joinpath("printer.cfg") self._log = self.log_dir.joinpath("klippy.log") self._serial = self.comms_dir.joinpath("klippy.serial") self._uds = self.comms_dir.joinpath("klippy.sock") @@ -153,9 +153,3 @@ class Klipper(BaseInstance): env_file_content = env_file_content.replace("%LOG%", str(self.log)) env_file_content = env_file_content.replace("%UDS%", str(self.uds)) return env_file_content - - def _get_cfg(self) -> Union[Path, None]: - cfg_file_loc = self.cfg_dir.joinpath("printer.cfg") - if cfg_file_loc.is_file(): - return cfg_file_loc - return None diff --git a/kiauh/modules/moonraker/moonraker.py b/kiauh/modules/moonraker/moonraker.py index 4a1ae12..78d60c7 100644 --- a/kiauh/modules/moonraker/moonraker.py +++ b/kiauh/modules/moonraker/moonraker.py @@ -31,7 +31,7 @@ class Moonraker(BaseInstance): super().__init__(instance_type=self, suffix=suffix) self.moonraker_dir: Path = MOONRAKER_DIR self.env_dir: Path = MOONRAKER_ENV_DIR - self.cfg_file = self._get_cfg() + self.cfg_file = self.cfg_dir.joinpath("moonraker.conf") self.port = self._get_port() self.backup_dir = self.data_dir.joinpath("backup") self.certs_dir = self.data_dir.joinpath("certs") @@ -138,14 +138,8 @@ class Moonraker(BaseInstance): ) return env_file_content - def _get_cfg(self) -> Union[Path, None]: - cfg_file_loc = self.cfg_dir.joinpath("moonraker.conf") - if cfg_file_loc.is_file(): - return cfg_file_loc - return None - def _get_port(self) -> Union[int, None]: - if self.cfg_file is None: + if not self.cfg_file.is_file(): return None cm = ConfigManager(cfg_file=self.cfg_file)