feat(BackupManager): implement simple backup manager

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2023-11-14 21:28:13 +01:00
parent 1392ca9f82
commit a4a3d5eecb
7 changed files with 133 additions and 10 deletions

25
kiauh/utils/common.py Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python
# ======================================================================= #
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
# #
# This file is part of KIAUH - Klipper Installation And Update Helper #
# https://github.com/dw-0/kiauh #
# #
# This file may be distributed under the terms of the GNU GPLv3 license #
# ======================================================================= #
from datetime import datetime
from typing import Dict, Literal
def get_current_date() -> Dict[Literal["date", "time"], str]:
"""
Get the current date |
:return: a Dict holding a date and time key:value pair
"""
now: datetime = datetime.today()
date: str = now.strftime("%Y-%m-%d")
time: str = now.strftime("%H-%M-%S")
return {"date": date, "time": time}

View File

@@ -11,6 +11,7 @@
import os
import pwd
from pathlib import Path
# text colors and formats
COLOR_MAGENTA = "\033[35m" # magenta
@@ -19,6 +20,8 @@ COLOR_YELLOW = "\033[93m" # bright yellow
COLOR_RED = "\033[91m" # bright red
COLOR_CYAN = "\033[96m" # bright cyan
RESET_FORMAT = "\033[0m" # reset format
# kiauh
KIAUH_BACKUP_DIR = f"{Path.home()}/kiauh-backups"
# current user
CURRENT_USER = pwd.getpwuid(os.getuid())[0]
SYSTEMD = "/etc/systemd/system"