diff --git a/kiauh/__init__.py b/kiauh/__init__.py index d30786d..662cd28 100644 --- a/kiauh/__init__.py +++ b/kiauh/__init__.py @@ -9,6 +9,7 @@ # This file may be distributed under the terms of the GNU GPLv3 license # # ======================================================================= # -from os.path import dirname, abspath +from os.path import join, dirname, abspath APPLICATION_ROOT = dirname(dirname(abspath(__file__))) +KIAUH_CFG = join(APPLICATION_ROOT, "kiauh.cfg") diff --git a/kiauh/core/config_manager/config_manager.py b/kiauh/core/config_manager/config_manager.py index a1cd757..593773f 100644 --- a/kiauh/core/config_manager/config_manager.py +++ b/kiauh/core/config_manager/config_manager.py @@ -9,19 +9,16 @@ # This file may be distributed under the terms of the GNU GPLv3 license # # ======================================================================= # -import os import configparser -from pathlib import Path from typing import Union -from kiauh import APPLICATION_ROOT from kiauh.utils.logger import Logger # noinspection PyMethodMayBeStatic class ConfigManager: - def __init__(self): - self.config_file = self._get_cfg_location() + def __init__(self, cfg_file: str): + self.config_file = cfg_file self.config = configparser.ConfigParser() def read_config(self) -> None: @@ -56,11 +53,3 @@ class ConfigManager: def set_value(self, section: str, key: str, value: str): self.config.set(section, key, value) - - def check_config_exist(self) -> bool: - return True if self._get_cfg_location() else False - - def _get_cfg_location(self) -> str: - cfg_path = os.path.join(APPLICATION_ROOT, "kiauh.cfg") - - return cfg_path if Path(cfg_path).exists() else None diff --git a/kiauh/modules/klipper/klipper_setup.py b/kiauh/modules/klipper/klipper_setup.py index fb00924..13008c3 100644 --- a/kiauh/modules/klipper/klipper_setup.py +++ b/kiauh/modules/klipper/klipper_setup.py @@ -14,6 +14,7 @@ import subprocess from pathlib import Path from typing import List, Union +from kiauh import KIAUH_CFG from kiauh.core.backup_manager.backup_manager import BackupManager from kiauh.core.config_manager.config_manager import ConfigManager from kiauh.core.instance_manager.instance_manager import InstanceManager @@ -135,7 +136,7 @@ def install_klipper( def setup_klipper_prerequesites() -> None: - cm = ConfigManager() + cm = ConfigManager(cfg_file=KIAUH_CFG) cm.read_config() repo = str(cm.get_value("klipper", "repository_url") or DEFAULT_KLIPPER_REPO_URL) @@ -255,7 +256,7 @@ def update_klipper() -> None: if not get_confirm("Update Klipper now?"): return - cm = ConfigManager() + cm = ConfigManager(cfg_file=KIAUH_CFG) cm.read_config() if cm.get_value("kiauh", "backup_before_update"):