mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-26 17:23:35 +05:00
refactor: make Moonraker to dataclass
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import CalledProcessError, run
|
from subprocess import CalledProcessError, run
|
||||||
|
|
||||||
@@ -28,11 +29,22 @@ from utils.logger import Logger
|
|||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
@dataclass
|
||||||
class Moonraker(BaseInstance):
|
class Moonraker(BaseInstance):
|
||||||
|
moonraker_dir: Path = MOONRAKER_DIR
|
||||||
|
env_dir: Path = MOONRAKER_ENV_DIR
|
||||||
|
cfg_file: Path = None
|
||||||
|
port: int = None
|
||||||
|
backup_dir: Path = None
|
||||||
|
certs_dir: Path = None
|
||||||
|
db_dir: Path = None
|
||||||
|
log: Path = None
|
||||||
|
|
||||||
def __init__(self, suffix: str = ""):
|
def __init__(self, suffix: str = ""):
|
||||||
super().__init__(instance_type=self, suffix=suffix)
|
super().__init__(instance_type=self, suffix=suffix)
|
||||||
self.moonraker_dir: Path = MOONRAKER_DIR
|
|
||||||
self.env_dir: Path = MOONRAKER_ENV_DIR
|
def __post_init__(self) -> None:
|
||||||
|
super().__post_init__()
|
||||||
self.cfg_file = self.cfg_dir.joinpath(MOONRAKER_CFG_NAME)
|
self.cfg_file = self.cfg_dir.joinpath(MOONRAKER_CFG_NAME)
|
||||||
self.port = self._get_port()
|
self.port = self._get_port()
|
||||||
self.backup_dir = self.data_dir.joinpath("backup")
|
self.backup_dir = self.data_dir.joinpath("backup")
|
||||||
|
|||||||
Reference in New Issue
Block a user