refactor: replace glob with iterdir

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2024-06-30 21:25:55 +02:00
parent 01deab7c64
commit c1f600f539
2 changed files with 5 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ from core.backup_manager import BACKUP_ROOT_DIR
MODULE_PATH = Path(__file__).resolve().parent
# names
KLIPPER_LOG_NAME = "klippy.log"
KLIPPER_DIR = Path.home().joinpath("klipper")
KLIPPER_ENV_DIR = Path.home().joinpath("klippy-env")
KLIPPER_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("klipper-backups")

View File

@@ -158,5 +158,8 @@ class Klipper(BaseInstance):
from utils.fs_utils import run_remove_routines
for log in list(self.log_dir.glob("klippy.log*")):
files = self.log_dir.iterdir()
logs = [f for f in files if f.name.startswith(KLIPPER_LOG_NAME)]
for log in logs:
Logger.print_status(f"Remove '{log}'")
run_remove_routines(log)