From fed513f0d7802071cc8da093a392a8dbe534c7b5 Mon Sep 17 00:00:00 2001 From: ahMAD ASSadi Date: Wed, 8 Jan 2025 15:28:33 +0330 Subject: [PATCH] Update some shite --- core/utils.sh | 2 +- menu.py | 43 ++++++++++++++++++++++++++++++++++--------- poetry.lock | 31 +++++++++++++++++++++++++++++++ pyproject.toml | 16 ++++++++++++++++ 4 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 poetry.lock create mode 100644 pyproject.toml diff --git a/core/utils.sh b/core/utils.sh index 42dbbaa..e6c4ab3 100644 --- a/core/utils.sh +++ b/core/utils.sh @@ -60,7 +60,7 @@ setup_logging() { log_file="$log_dir/logs.log" fi - exec > >(tee >(strip_colors >>"$log_file")) 2>&1 + # exec > >(tee >(strip_colors >>"$log_file")) 2>&1 echo -e "$(colorize $COLOR_BLUE "Created at: $(date +"%Y-%m-%d_%H-%M-%S")")" } diff --git a/menu.py b/menu.py index c01bab8..ebb6b57 100644 --- a/menu.py +++ b/menu.py @@ -1,3 +1,9 @@ +from colorama import init as colorama_init +from colorama import Fore,Back +from colorama import Style +import os + +colorama_init() logo = """ █████ █████ █████████ ███████████ ░░███ ░░███ ███░░░░░███░█░░░███░░░█ @@ -10,16 +16,35 @@ """ +def center_text(text: str) -> str: + """ + Centers text for terminal output based on the terminal width. + """ + terminal_width = os.get_terminal_size().columns + lines = text.splitlines() + centered_lines = [ + line.center(terminal_width) for line in lines + ] + return "\n".join(centered_lines) + + def display_menu(): """Displays a menu of options to the user.""" - print(logo) - print("Welcome to the Ubuntu Configuration Tool(UCT)") - print("Please choose an option:") - print("0: See and Update the configuration file") - print("1: Install apps") - print("2: Test ping of the vpn servers") + # Display the logo + print(f"{Back.BLACK}{Fore.CYAN}{center_text(logo)}{Style.RESET_ALL}") + + # Display the menu options + menu_text = """ +Welcome to the Ubuntu Configuration Tool (UCT) +Please choose an option: +0: See and Update the configuration file +1: Install apps +2: Test ping of the VPN servers + +q: Exit +""" + print(f"{Fore.MAGENTA}{center_text(menu_text)}{Style.RESET_ALL}") - print("q: Exit") def get_user_choice() -> int: @@ -31,8 +56,8 @@ def get_user_choice() -> int: while True: try: choice = (input("Enter your choice: ")) - if choice in [0, 1, 2, 3]: - return choice + if not choice == "q": + return int(choice) elif choice == "q": return choice else: diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..4b83e8a --- /dev/null +++ b/poetry.lock @@ -0,0 +1,31 @@ +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "termcolor" +version = "2.5.0" +description = "ANSI color formatting for output in terminal" +optional = false +python-versions = ">=3.9" +files = [ + {file = "termcolor-2.5.0-py3-none-any.whl", hash = "sha256:37b17b5fc1e604945c2642c872a3764b5d547a48009871aea3edd3afa180afb8"}, + {file = "termcolor-2.5.0.tar.gz", hash = "sha256:998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f"}, +] + +[package.extras] +tests = ["pytest", "pytest-cov"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.12" +content-hash = "466fe41de02997ac74cfa6eb9c66e7eb8d5aa764667a77be4c4a4176b52826a7" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a2cf229 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[tool.poetry] +name = "ubuntu-configuration-template" +version = "0.1.0" +description = "A Simple configuration tool for ubuntu" +authors = ["ahMAD ASSadi "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.12" +termcolor = "^2.5.0" +colorama = "^0.4.6" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"