mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-23 15:53:36 +05:00
chore: fix lint issues
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
import textwrap
|
||||
from enum import Enum, unique
|
||||
from typing import List, Union, Literal
|
||||
from typing import List
|
||||
|
||||
from core.instance_manager.base_instance import BaseInstance
|
||||
from core.menus.base_menu import print_back_footer
|
||||
|
||||
@@ -50,5 +50,5 @@ def upload_logfile(logfile: LogFile) -> None:
|
||||
Logger.print_ok("Upload successful! Access it via the following link:")
|
||||
Logger.print_ok(f">>>> {link}", False)
|
||||
except Exception as e:
|
||||
Logger.print_error(f"Uploading logfile failed!")
|
||||
Logger.print_error("Uploading logfile failed!")
|
||||
Logger.print_error(str(e))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# ======================================================================= #
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Literal, TypedDict, Set
|
||||
from typing import Literal, TypedDict
|
||||
|
||||
from core.backup_manager import BACKUP_ROOT_DIR
|
||||
|
||||
|
||||
@@ -16,34 +16,34 @@ from core.instance_manager.base_instance import BaseInstance
|
||||
from utils.constants import SYSTEMD
|
||||
from utils.logger import Logger
|
||||
|
||||
I = TypeVar(name="I", bound=BaseInstance, covariant=True)
|
||||
T = TypeVar(name="T", bound=BaseInstance, covariant=True)
|
||||
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
class InstanceManager:
|
||||
def __init__(self, instance_type: I) -> None:
|
||||
def __init__(self, instance_type: T) -> None:
|
||||
self._instance_type = instance_type
|
||||
self._current_instance: Optional[I] = None
|
||||
self._current_instance: Optional[T] = None
|
||||
self._instance_suffix: Optional[str] = None
|
||||
self._instance_service: Optional[str] = None
|
||||
self._instance_service_full: Optional[str] = None
|
||||
self._instance_service_path: Optional[str] = None
|
||||
self._instances: List[I] = []
|
||||
self._instances: List[T] = []
|
||||
|
||||
@property
|
||||
def instance_type(self) -> I:
|
||||
def instance_type(self) -> T:
|
||||
return self._instance_type
|
||||
|
||||
@instance_type.setter
|
||||
def instance_type(self, value: I):
|
||||
def instance_type(self, value: T):
|
||||
self._instance_type = value
|
||||
|
||||
@property
|
||||
def current_instance(self) -> I:
|
||||
def current_instance(self) -> T:
|
||||
return self._current_instance
|
||||
|
||||
@current_instance.setter
|
||||
def current_instance(self, value: I) -> None:
|
||||
def current_instance(self, value: T) -> None:
|
||||
self._current_instance = value
|
||||
self.instance_suffix = value.suffix
|
||||
self.instance_service = value.get_service_file_name()
|
||||
@@ -78,11 +78,11 @@ class InstanceManager:
|
||||
self._instance_service_path = value
|
||||
|
||||
@property
|
||||
def instances(self) -> List[I]:
|
||||
def instances(self) -> List[T]:
|
||||
return self.find_instances()
|
||||
|
||||
@instances.setter
|
||||
def instances(self, value: List[I]):
|
||||
def instances(self, value: List[T]):
|
||||
self._instances = value
|
||||
|
||||
def create_instance(self) -> None:
|
||||
@@ -182,7 +182,7 @@ class InstanceManager:
|
||||
Logger.print_error(f"{e}")
|
||||
raise
|
||||
|
||||
def find_instances(self) -> List[I]:
|
||||
def find_instances(self) -> List[T]:
|
||||
name = self.instance_type.__name__.lower()
|
||||
pattern = re.compile(f"^{name}(-[0-9a-zA-Z]+)?.service$")
|
||||
excluded = self.instance_type.blacklist()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
# ======================================================================= #
|
||||
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||
@@ -209,11 +208,10 @@ def add_config_section(
|
||||
|
||||
cm.write_config()
|
||||
|
||||
def add_config_section_at_top(
|
||||
section: str,
|
||||
instances: List[B]):
|
||||
|
||||
def add_config_section_at_top(section: str, instances: List[B]):
|
||||
for instance in instances:
|
||||
tmp_cfg = tempfile.NamedTemporaryFile(mode="w" ,delete=False)
|
||||
tmp_cfg = tempfile.NamedTemporaryFile(mode="w", delete=False)
|
||||
tmp_cfg_path = Path(tmp_cfg.name)
|
||||
cmt = ConfigManager(tmp_cfg_path)
|
||||
cmt.config.add_section(section)
|
||||
|
||||
Reference in New Issue
Block a user