From 21c62dbe9c547558ecf7e43a59f04f6d6d4844d4 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 17:39:25 +0800 Subject: [PATCH 001/240] for custom logging --- src/utils/logger.py | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 src/utils/logger.py diff --git a/src/utils/logger.py b/src/utils/logger.py new file mode 100755 index 0000000..04817d9 --- /dev/null +++ b/src/utils/logger.py @@ -0,0 +1,65 @@ +import logging +from pathlib import Path +from os import mkdir +from os.path import exists + +from rich.logging import RichHandler + + +class Logger: + """Custom logger.""" + + def __init__(self, filename: str = "sayu") -> None: + """ + Args: + filename -- filename to use. + """ + + logging.basicConfig( + format="%(message)s", + level=logging.INFO, + datefmt="[%X]", + handlers=[ + RichHandler( + show_time=False, + show_path=False + ) + ] + ) + + self.log: logging.Logger = logging.getLogger("rich") + + BASE_PATH: Path = Path.home()/".sayu" + if not exists(BASE_PATH): + try: + mkdir(BASE_PATH) + except (PermissionError, OSError, IOError) as Err: + self.logger( + "E", f"Cannot create directory: {Err}, aborting ..." + ) + + file_log: logging.FileHandler = logging.FileHandler( + filename=f"{BASE_PATH}/{filename}.log" + ) + + file_log.setLevel(logging.INFO) + file_log.setFormatter( + logging.Formatter("%(levelname)s %(message)s") + ) + self.log.addHandler(file_log) + + def logger(self, exception_: str, message: str) -> None: + """Log the proccesses using passed message and exception_ variable. + + Args: + exception_ -- determines what type of log level to use + message -- message to be logged. + """ + + match exception_: + case "E": # for major error + self.log.critical("%s" % (message)) + case "e": + self.log.error("%s" % (message)) + case "I": # to print information in the terminal + self.log.info("%s" % (message)) From ecf9330fa5a57ff52893c273e0267789e96c1e7f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 17:39:57 +0800 Subject: [PATCH 002/240] python dependencies --- REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) create mode 100644 REQUIREMENTS diff --git a/REQUIREMENTS b/REQUIREMENTS new file mode 100644 index 0000000..9005c4b --- /dev/null +++ b/REQUIREMENTS @@ -0,0 +1 @@ +rich==12.6.0 From 489bcae4b49f367262787c27cad4f505be78a2e8 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 17:40:44 +0800 Subject: [PATCH 003/240] restructure log --- src/utils/log/__init__.py | 0 src/utils/{ => log}/logger.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/log/__init__.py rename src/utils/{ => log}/logger.py (100%) diff --git a/src/utils/log/__init__.py b/src/utils/log/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/logger.py b/src/utils/log/logger.py similarity index 100% rename from src/utils/logger.py rename to src/utils/log/logger.py From 3dc4759fc1bf2a154d838ab5dea03368b0f3049d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 17:41:30 +0800 Subject: [PATCH 004/240] core subpackage --- src/utils/core/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/__init__.py diff --git a/src/utils/core/__init__.py b/src/utils/core/__init__.py new file mode 100644 index 0000000..e69de29 From d5c7fd87a03b0ba41a1c33ab6d2b5d59dd49f401 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 17:41:56 +0800 Subject: [PATCH 005/240] shared subpackage --- src/utils/shared/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/shared/__init__.py diff --git a/src/utils/shared/__init__.py b/src/utils/shared/__init__.py new file mode 100644 index 0000000..e69de29 From a223cda1b739ff8b06af6d3cc1503057e296f61f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 17:48:58 +0800 Subject: [PATCH 006/240] misc and interface subpackage --- src/interface/__init__.py | 0 src/utils/misc/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/interface/__init__.py create mode 100644 src/utils/misc/__init__.py diff --git a/src/interface/__init__.py b/src/interface/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/misc/__init__.py b/src/utils/misc/__init__.py new file mode 100644 index 0000000..e69de29 From f9786a49d7ae585c73254e5b68393f40b5097ee3 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:02:31 +0800 Subject: [PATCH 007/240] module to simplify user input --- src/utils/misc/uinput.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/utils/misc/uinput.py diff --git a/src/utils/misc/uinput.py b/src/utils/misc/uinput.py new file mode 100644 index 0000000..0a4ed84 --- /dev/null +++ b/src/utils/misc/uinput.py @@ -0,0 +1,39 @@ +from typing import Any + +from rich.console import Console + + +def uinput(console: Console, msg: str, qtype: int) -> Any: + """Takes user input and return the evaluated output. + + Args: + console -- Console instance + msg -- question to ask the user + qtype -- question type, whether y/N, string input or number input + 1 is yes or no input + 2 is number/list input + + Returns: + The evaluated input based on the user response, e.g.: + y -> True + N -> False + 1, 2, 3 -> list[int] + """ + + match qtype: + case 1: + console.print( + f"{msg} [bold][[green]y[/green]/[red]N[/red]][/bold]", end=" " + ) + if input().lower().strip() == "y": + return True + case 2: + console.print( + ( + f"{msg} [bold][NUMBER/LIST INPUT" + ", separate by comma ','][/bold]" + ), end=" " + ) + return input() + + return False From 245daf70ec4d912cf5dd80891da5c390668b501d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:13:04 +0800 Subject: [PATCH 008/240] module for execution or system calls --- src/utils/shared/exec.py | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/utils/shared/exec.py diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py new file mode 100644 index 0000000..92244fc --- /dev/null +++ b/src/utils/shared/exec.py @@ -0,0 +1,47 @@ +from shutil import which +from subprocess import run, CalledProcessError, DEVNULL +from typing import NoReturn + +from src.utils.log.logger import Logger + + +def execute_command( + log: Logger, command: list[str], verbose: bool = False + ) -> NoReturn | None: + """For command execution/system calls with error handling + + Args: + log -- Logger instance + command -- command to execute with arguments + + Returns: + None or raise system exit + """ + + try: + if which(command[0]) is None: + log.logger( + "E", f"Program: {command[0]} does not exists, aborting ..." + ) + raise SystemExit + + if verbose: + return_code: int = run(command).returncode + else: + return_code: int = run(command, stdout=DEVNULL).returncode + + if return_code != 0: + raise CalledProcessError(return_code, command) + else: + log.logger("I", f"Successfully executed the command: {command}") + except (OSError, CalledProcessError) as Err: + log.logger( + "E", + ( + f"{Err} encountered, cannot execute" + " command: {command}, aborting ..." + ) + ) + raise SystemExit + + return None From a8db4ec4c096499fe953319b1e703530e75b2ac8 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:24:39 +0800 Subject: [PATCH 009/240] include case for string/char input --- src/utils/misc/uinput.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/misc/uinput.py b/src/utils/misc/uinput.py index 0a4ed84..5c5c6b4 100644 --- a/src/utils/misc/uinput.py +++ b/src/utils/misc/uinput.py @@ -12,6 +12,7 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: qtype -- question type, whether y/N, string input or number input 1 is yes or no input 2 is number/list input + 3 is for string or char input Returns: The evaluated input based on the user response, e.g.: @@ -35,5 +36,13 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: ), end=" " ) return input() + case 3: + console.print( + ( + f"{msg} [bold][CHAR/STRING INPUT" + ", separate by comma ','][/bold]" + ), end=" " + ) + return input() return False From 2a67120172d327cfa6877a1e7520549fe14c75a1 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:33:40 +0800 Subject: [PATCH 010/240] rename the folder and the file log name --- src/utils/log/logger.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/log/logger.py b/src/utils/log/logger.py index 04817d9..25cf90c 100755 --- a/src/utils/log/logger.py +++ b/src/utils/log/logger.py @@ -9,7 +9,7 @@ class Logger: """Custom logger.""" - def __init__(self, filename: str = "sayu") -> None: + def __init__(self, filename: str = "log") -> None: """ Args: filename -- filename to use. @@ -29,7 +29,7 @@ def __init__(self, filename: str = "sayu") -> None: self.log: logging.Logger = logging.getLogger("rich") - BASE_PATH: Path = Path.home()/".sayu" + BASE_PATH: Path = Path.home()/".log" if not exists(BASE_PATH): try: mkdir(BASE_PATH) From eb1c13531998c15b1d5814be9dc42f092174afdd Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:35:38 +0800 Subject: [PATCH 011/240] for fetching of environment variable --- src/utils/shared/fetch_env.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/utils/shared/fetch_env.py diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py new file mode 100644 index 0000000..a447753 --- /dev/null +++ b/src/utils/shared/fetch_env.py @@ -0,0 +1,28 @@ +from os import getenv + +from rich.console import Console + +from src.utils.misc.uinput import uinput +from src.utils.log.logger import Logger + + +def fetch_env(log: Logger, console: Console, env_var: str) -> str: + """Fetch the value of given env variable. + + Args: + log -- instance of Logger + env_var -- variable to fetch + + Returns: + The value of env variable or None + """ + + try: + env_value: str = getenv(env_var.upper()) + except OSError as Err: + log.logger("e", f"{Err}. No value found for {env_var}.") + env_value = uinput( + console, f"Kindly input the value for {env_var}" + ) + + return env_value From 830267853fab89c883c9b79e60e2c1a9a120a2f9 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:36:33 +0800 Subject: [PATCH 012/240] commandline interface --- src/interface/cli.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/interface/cli.py diff --git a/src/interface/cli.py b/src/interface/cli.py new file mode 100644 index 0000000..e69de29 From 7d84cd1af342c9daef99f182ad981b8a9966f882 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:38:38 +0800 Subject: [PATCH 013/240] for package related data --- src/data/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/data/__init__.py diff --git a/src/data/__init__.py b/src/data/__init__.py new file mode 100644 index 0000000..e69de29 From cb7d4c197d7bdefbda70bc4a24bfdc35e7c49eb1 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:44:11 +0800 Subject: [PATCH 014/240] dataclass for unused apps --- src/data/unused_apps.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/data/unused_apps.py diff --git a/src/data/unused_apps.py b/src/data/unused_apps.py new file mode 100644 index 0000000..eb6d887 --- /dev/null +++ b/src/data/unused_apps.py @@ -0,0 +1,24 @@ +from dataclasses import dataclass + + +@dataclass(frozen=True) +class UnusedApps: + """List of unused apps""" + + flatpaks_unused_apps: dict[str, str] = { + "calculator": "org.gnome.Calculator", + "calendar": "org.gnome.Calendar", + "characters": "org.gnome.Characters", + "connections": "org.gnome.Connections", + "contacts": "org.gnome.Contacts", + "Document Viewer": "org.gnome.Evince", + "extensions": "org.gnome.Extensions", + "logs": "org.gnome.Logs", + "maps": "org.gnome.Maps", + "text editor": "org.gnome.TextEditor", + "weather": "org.gnome.Weather", + "disk usage analyzer": "org.gnome.baobab", + "clocks": "org.gnome.Clocks", + "image viewer": "org.gnome.eog", + "fonts": "org.gnome.fonts-viewer", + } From 920a34e58d50eb7db41d5659a09ef0d8d47f206c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:47:40 +0800 Subject: [PATCH 015/240] dataclass of the apps to be installed --- src/data/app_for_install.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/data/app_for_install.py diff --git a/src/data/app_for_install.py b/src/data/app_for_install.py new file mode 100644 index 0000000..f802440 --- /dev/null +++ b/src/data/app_for_install.py @@ -0,0 +1,15 @@ +from dataclasses import dataclass + + +@dataclass +class GetApps: + """Apps to be installed""" + + recommend_list: dict[str, str] = { + "mailspring": "com.getmailspring.Mailspring", + "libreoffice": "org.libreoffice.LibreOffice", + "vlc": "org.videolan.VLC", + "okular": "org.kde.okular", + "gimp": "org.gimp.GIMP" + } + selected_app: list[str] = None From 5ce448664ef3b0438a96c848aadeb15dcdead687 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:48:55 +0800 Subject: [PATCH 016/240] for developers --- DEV_REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) create mode 100644 DEV_REQUIREMENTS diff --git a/DEV_REQUIREMENTS b/DEV_REQUIREMENTS new file mode 100644 index 0000000..2e62f66 --- /dev/null +++ b/DEV_REQUIREMENTS @@ -0,0 +1 @@ +mypy==0.971 From ea9d04e4638d6e18b8bb794fc89dbd8e69ea111a Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 24 Dec 2022 18:50:00 +0800 Subject: [PATCH 017/240] for checking of type annotations --- check.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 check.sh diff --git a/check.sh b/check.sh new file mode 100644 index 0000000..7222a1e --- /dev/null +++ b/check.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +mypy --strict $(git ls-files "*.py") From c78901fec573ac4e2bc2c90ec8d62624a3568bce Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 21:42:35 +0800 Subject: [PATCH 018/240] update permissions --- .gitignore | 0 DEV_REQUIREMENTS | 0 LICENSE | 0 README.md | 0 REQUIREMENTS | 0 ToDo.md | 0 check.sh | 0 script1.sh | 0 script2.sh | 0 src/data/__init__.py | 0 src/data/app_for_install.py | 0 src/data/unused_apps.py | 0 src/interface/__init__.py | 0 src/interface/cli.py | 0 src/main.py | 0 src/utils/__init__.py | 0 src/utils/core/__init__.py | 0 src/utils/log/__init__.py | 0 src/utils/misc/__init__.py | 0 src/utils/misc/uinput.py | 0 src/utils/shared/__init__.py | 0 src/utils/shared/exec.py | 0 src/utils/shared/fetch_env.py | 0 23 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 DEV_REQUIREMENTS mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 REQUIREMENTS mode change 100644 => 100755 ToDo.md mode change 100644 => 100755 check.sh mode change 100644 => 100755 script1.sh mode change 100644 => 100755 script2.sh mode change 100644 => 100755 src/data/__init__.py mode change 100644 => 100755 src/data/app_for_install.py mode change 100644 => 100755 src/data/unused_apps.py mode change 100644 => 100755 src/interface/__init__.py mode change 100644 => 100755 src/interface/cli.py mode change 100644 => 100755 src/main.py mode change 100644 => 100755 src/utils/__init__.py mode change 100644 => 100755 src/utils/core/__init__.py mode change 100644 => 100755 src/utils/log/__init__.py mode change 100644 => 100755 src/utils/misc/__init__.py mode change 100644 => 100755 src/utils/misc/uinput.py mode change 100644 => 100755 src/utils/shared/__init__.py mode change 100644 => 100755 src/utils/shared/exec.py mode change 100644 => 100755 src/utils/shared/fetch_env.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/DEV_REQUIREMENTS b/DEV_REQUIREMENTS old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/REQUIREMENTS b/REQUIREMENTS old mode 100644 new mode 100755 diff --git a/ToDo.md b/ToDo.md old mode 100644 new mode 100755 diff --git a/check.sh b/check.sh old mode 100644 new mode 100755 diff --git a/script1.sh b/script1.sh old mode 100644 new mode 100755 diff --git a/script2.sh b/script2.sh old mode 100644 new mode 100755 diff --git a/src/data/__init__.py b/src/data/__init__.py old mode 100644 new mode 100755 diff --git a/src/data/app_for_install.py b/src/data/app_for_install.py old mode 100644 new mode 100755 diff --git a/src/data/unused_apps.py b/src/data/unused_apps.py old mode 100644 new mode 100755 diff --git a/src/interface/__init__.py b/src/interface/__init__.py old mode 100644 new mode 100755 diff --git a/src/interface/cli.py b/src/interface/cli.py old mode 100644 new mode 100755 diff --git a/src/main.py b/src/main.py old mode 100644 new mode 100755 diff --git a/src/utils/__init__.py b/src/utils/__init__.py old mode 100644 new mode 100755 diff --git a/src/utils/core/__init__.py b/src/utils/core/__init__.py old mode 100644 new mode 100755 diff --git a/src/utils/log/__init__.py b/src/utils/log/__init__.py old mode 100644 new mode 100755 diff --git a/src/utils/misc/__init__.py b/src/utils/misc/__init__.py old mode 100644 new mode 100755 diff --git a/src/utils/misc/uinput.py b/src/utils/misc/uinput.py old mode 100644 new mode 100755 diff --git a/src/utils/shared/__init__.py b/src/utils/shared/__init__.py old mode 100644 new mode 100755 diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py old mode 100644 new mode 100755 diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py old mode 100644 new mode 100755 From 95832fb3b85a51c3197bbcd88198f07e75796c4d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 21:56:05 +0800 Subject: [PATCH 019/240] include descriptions for app --- src/data/app_for_install.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/data/app_for_install.py b/src/data/app_for_install.py index f802440..e949da9 100755 --- a/src/data/app_for_install.py +++ b/src/data/app_for_install.py @@ -5,11 +5,26 @@ class GetApps: """Apps to be installed""" - recommend_list: dict[str, str] = { - "mailspring": "com.getmailspring.Mailspring", - "libreoffice": "org.libreoffice.LibreOffice", - "vlc": "org.videolan.VLC", - "okular": "org.kde.okular", - "gimp": "org.gimp.GIMP" + recommend_list: dict[str, dict[str, str]] = { + "mailspring": { + "aid": "com.getmailspring.Mailspring", + "simple_description": "A simple email client." + }, + "libreoffice": { + "aid": "org.libreoffice.LibreOffice", + "simple_description": "Office suite." + }, + "vlc": { + "aid": "org.videolan.VLC", + "simple_description": "Video player." + }, + "okular": { + "aid": "org.kde.okular", + "simple_description": "A document viewer." + }, + "gimp": { + "aid": "org.gimp.GIMP", + "simple_description": "Photo editing application." + } } selected_app: list[str] = None From 88a9b90f06f3be16496160e1ecb2df9fdd5c5548 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 22:10:15 +0800 Subject: [PATCH 020/240] module for checking the gpu in the system --- src/utils/core/gpu_install.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/utils/core/gpu_install.py diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py new file mode 100644 index 0000000..a792469 --- /dev/null +++ b/src/utils/core/gpu_install.py @@ -0,0 +1,34 @@ +from subprocess import ( + Popen, + CalledProcessError, + PIPE, + check_output +) + +from src.utils.log.logger import Logger + + +def fetch_gpu(log: Logger) -> str | None: + """Fetch the GPU of the system. + + Args: + log -- instance of Logger + + Returns: + The name of GPU or None. + """ + + try: + lspci_out = Popen(("lspci"), stdout=PIPE) + gpu_name: str = check_output( + ["grep", "-i", "VGA"], stdin=lspci_out.stdout + ) + lspci_out.wait() + + if lspci_out.returncode != 0: + raise SystemExit(["lspci"], lspci_out.returncode) + except CalledProcessError as Err: + log.logger("e", f"{Err}. Command lspci failed to execute.") + return None + else: + return gpu_name From 036d40b056f25be14d38eff8111d779874dc7d68 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 22:14:55 +0800 Subject: [PATCH 021/240] handle file not found exception when the command executable is not found --- src/utils/core/gpu_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index a792469..b2ba13f 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -27,7 +27,7 @@ def fetch_gpu(log: Logger) -> str | None: if lspci_out.returncode != 0: raise SystemExit(["lspci"], lspci_out.returncode) - except CalledProcessError as Err: + except (CalledProcessError, FileNotFoundError) as Err: log.logger("e", f"{Err}. Command lspci failed to execute.") return None else: From 5a34348f052ae316c1001dd70d072c6bf69308d2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 22:23:18 +0800 Subject: [PATCH 022/240] update the return output for easier parsing --- src/utils/core/gpu_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index b2ba13f..bc261bb 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -8,7 +8,7 @@ from src.utils.log.logger import Logger -def fetch_gpu(log: Logger) -> str | None: +def fetch_gpu(log: Logger) -> tuple[str, str | None] | None: """Fetch the GPU of the system. Args: @@ -31,4 +31,4 @@ def fetch_gpu(log: Logger) -> str | None: log.logger("e", f"{Err}. Command lspci failed to execute.") return None else: - return gpu_name + return gpu_name.decode("utf-8").strip().split("\n") From c039c9629eea2d608e5ae1c919878012ccde4fa6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 22:48:46 +0800 Subject: [PATCH 023/240] include clamtk and flatseal --- src/data/app_for_install.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/data/app_for_install.py b/src/data/app_for_install.py index e949da9..f13750a 100755 --- a/src/data/app_for_install.py +++ b/src/data/app_for_install.py @@ -5,26 +5,39 @@ class GetApps: """Apps to be installed""" + #* takes the name of the app, then a dictionary which includes the + #* application id, and then a simple description for the given app recommend_list: dict[str, dict[str, str]] = { - "mailspring": { + "Mailspring": { "aid": "com.getmailspring.Mailspring", "simple_description": "A simple email client." }, - "libreoffice": { + "LibreOffice": { "aid": "org.libreoffice.LibreOffice", "simple_description": "Office suite." }, - "vlc": { + "VLC": { "aid": "org.videolan.VLC", "simple_description": "Video player." }, - "okular": { + "Okular": { "aid": "org.kde.okular", "simple_description": "A document viewer." }, - "gimp": { + "GIMP": { "aid": "org.gimp.GIMP", "simple_description": "Photo editing application." + }, + "ClamTk": { + "aid": "com.gitlab.davem.ClamTk", + "simple_description": "Front end for ClamAV." + }, + "FlatSeal": { + "aid": "com.github.tchx84.Flatseal", + "simple_description": ( + "GUI for managing flatpak" + " applications permission" + ) } } selected_app: list[str] = None From 2faca7a7dd8f848c63227456f40ad45389b9781d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 23:47:28 +0800 Subject: [PATCH 024/240] parse the return value for the gpu name --- src/utils/core/gpu_install.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index bc261bb..46f4b98 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -31,4 +31,11 @@ def fetch_gpu(log: Logger) -> tuple[str, str | None] | None: log.logger("e", f"{Err}. Command lspci failed to execute.") return None else: - return gpu_name.decode("utf-8").strip().split("\n") + return [ + gpu.split(":") for gpu in ( + gpu_name + .decode("utf-8") + .strip() + .split("\n") + ) + ] From aa3aecdf5eee16be6ae4870b12ad12b0cef7d2ed Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 23:50:06 +0800 Subject: [PATCH 025/240] fix type annotation for function return --- src/utils/core/gpu_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 46f4b98..a3537a4 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -8,7 +8,7 @@ from src.utils.log.logger import Logger -def fetch_gpu(log: Logger) -> tuple[str, str | None] | None: +def fetch_gpu(log: Logger) -> list[str] | None: """Fetch the GPU of the system. Args: From 24df96538ddc0529a58f39715750981b02cbf1d4 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 25 Dec 2022 23:55:20 +0800 Subject: [PATCH 026/240] EXPERIMENTAL: module to determine the appropriate gpu based on lspci output #5 --- src/utils/core/gpu_install.py | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index a3537a4..b246a49 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -39,3 +39,51 @@ def fetch_gpu(log: Logger) -> list[str] | None: .split("\n") ) ] + + +def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: + """Append the appropriate driver in the list for GPU installation. + + Args: + log -- instance of Logger + + Returns: + true if the GPU was installed successfully or if there is + no driver to install and false if otherwise. + """ + + #! THIS IS EXPERIMENTAL AND NOT TESTED DUE TO LACK OF HARDWARE + #! SHOULD NOT BE CALLED YET ON THE MAIN FUNCTION IN MAIN.PY + #! ALTHOUGH THIS CAN BE ENABLED USING A FLAG `ex` IN THE CLI + #! BUT NOT IN DEFAULT OPTIONS, DO IT IN YOUR OWN DISCRETION + + + gpu_list: list[str] | None = fetch_gpu(log) + + if gpu is None: + log.logger( + "I", "There is no GPU driver to install, skipping ..." + ) + return None + + gpu_drivers: dict[str | list[str], list[str]] = { + "nvidia": ["akmod-nvidia", "xorg-x11-drv-nvidia"], + } + + for gpu in gpu_list: + vendor: str; gpu_info: list[str] | str + vendor, *gpu_info = gpu + + match [vendor, gpu_info]: + case ["nvidia", *gpu_info]: + drv_id: str = "nvidia" + case ["intel", *gpu_info]: + ... + case ["advanced micro devices", *gpu_info]: + ... + case _: + continue + + install_list.extend(gpu_drivers[drv_id]) + + return None From f48ae959f924631c4d4153a65183d1191d21d043 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 26 Dec 2022 00:12:43 +0800 Subject: [PATCH 027/240] initial commit for third repo install #6 --- src/utils/core/third_repo_install.py | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/utils/core/third_repo_install.py diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/third_repo_install.py new file mode 100644 index 0000000..667550f --- /dev/null +++ b/src/utils/core/third_repo_install.py @@ -0,0 +1,43 @@ +from rich.console import Console + +from src.utils.misc.uinput import uinput +from src.utils.log.logger import Logger + + +def third_repo_install( + log: Logger, console: Console, commands: list[str] + ) -> None: + """Install third party repositories.""" + + tp_repo: dict[int, dict[str, str]] = { + # id and name of the repo and the address + 1: { + "name": "RPMFusion (Free)", + "desc": "Fedora repository for open source softwares.", + "address": ( + r"https://mirrors.rpmfusion.org/" + r"free/fedora/rpmfusion-free-release" + r"-$(rpm -E %fedora).noarch.rpm" + ) + }, + 2: { + "name": "RPMFusion (Non-free)", + "desc": "Fedora repository for propietary software.", + "address": ( + r"https://mirrors.rpmfusion.org/" + r"nonfree/fedora/rpmfusion-nonfree" + r"-release-$(rpm -E %fedora).noarch.rpm" + ) + }, + 3: { + "name": "Flathub", + "desc": "Unfiltered repository for flatpaks.", + "address": "https://flathub.org/repo/flathub.flatpakrepo" + } + } + + for info in tp_repo.values(): + if uinput( + console, f"Install {info.get('name')} ({info.get('desc')})", 1 + ): + commands.append() From f4d2f892f625cfff8bfc21436838ee8a57500daf Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sun, 25 Dec 2022 17:13:23 +0000 Subject: [PATCH 028/240] Update ToDo.md --- ToDo.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ToDo.md b/ToDo.md index 1603d9b..64421f6 100644 --- a/ToDo.md +++ b/ToDo.md @@ -74,6 +74,7 @@ the other repos are pretty unnesscary for normal users, this is to mention ## 10. Installing rpm-packages - NOTIFICATION: "You can do other stuff now, installing takes a while...", best as notification in the tray? +- `notify-send 'title' 'message'` - TIP: To list available dnf packages, you can enter a toolbox (toolbox create 1 && toolbox enter 1 && dnf list) or layer dnfdragora (sudo rpm-ostree install dnfdragora), as rpm-ostree doesnt support that currently - Speed: use extra script that is generated using appending the names - As if want to game and use the custom RPM Proton https://github.com/GloriousEggroll/proton-ge-custom or the flatpak one without patches From 09bd35ec0c8ddda560728a395794c6aa857d1235 Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sun, 25 Dec 2022 17:17:20 +0000 Subject: [PATCH 029/240] added zenity gui notification example --- ToDo.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ToDo.md b/ToDo.md index 1603d9b..6f527fa 100644 --- a/ToDo.md +++ b/ToDo.md @@ -74,6 +74,7 @@ the other repos are pretty unnesscary for normal users, this is to mention ## 10. Installing rpm-packages - NOTIFICATION: "You can do other stuff now, installing takes a while...", best as notification in the tray? +- `zenity --info --text="Installing packages...\n\nYou can do other stuff now\." --title="Info\!"` - TIP: To list available dnf packages, you can enter a toolbox (toolbox create 1 && toolbox enter 1 && dnf list) or layer dnfdragora (sudo rpm-ostree install dnfdragora), as rpm-ostree doesnt support that currently - Speed: use extra script that is generated using appending the names - As if want to game and use the custom RPM Proton https://github.com/GloriousEggroll/proton-ge-custom or the flatpak one without patches From 807a605032a1f0629169a26705049ffcdc5c6f71 Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sun, 25 Dec 2022 23:10:49 +0000 Subject: [PATCH 030/240] java and perl as options --- ToDo.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ToDo.md b/ToDo.md index 1603d9b..496646d 100644 --- a/ToDo.md +++ b/ToDo.md @@ -78,6 +78,7 @@ the other repos are pretty unnesscary for normal users, this is to mention - Speed: use extra script that is generated using appending the names - As if want to game and use the custom RPM Proton https://github.com/GloriousEggroll/proton-ge-custom or the flatpak one without patches - sudo rpm-ostree override remove libavcodec-free --install exiftool perl-Image-ExifTool clamtk* fail2ban tlp make gcc-c++ qemu-kvm qemu-img qemu-user-static ffmpegthumbs kffmpegthumbnailer #libfprint unrar stacer pip android-tools btfs +- optional: install java, perl, not preinstalled `printf "appnamex " >> ~/Fedora-OSTree-setup/rpm-install.sh` From 9ae6e6523675078bab930163f4be0f41577bd733 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 20:34:47 +0800 Subject: [PATCH 031/240] for installation of third party repo #6 --- src/utils/core/third_repo_install.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/third_repo_install.py index 667550f..9089417 100644 --- a/src/utils/core/third_repo_install.py +++ b/src/utils/core/third_repo_install.py @@ -1,13 +1,21 @@ from rich.console import Console from src.utils.misc.uinput import uinput -from src.utils.log.logger import Logger def third_repo_install( - log: Logger, console: Console, commands: list[str] + console: Console, + commands: list[str], + rpmfusion_repo: list[str] ) -> None: - """Install third party repositories.""" + """Install third party repositories. + + Args: + log -- instance of Logger + console -- instance of Console + commands -- list of commands for execution + rpmfusion_repo -- list of packages to be installed + """ tp_repo: dict[int, dict[str, str]] = { # id and name of the repo and the address @@ -40,4 +48,14 @@ def third_repo_install( if uinput( console, f"Install {info.get('name')} ({info.get('desc')})", 1 ): - commands.append() + if info.get("name").lower() == "flathub": + commands.append( + ( + "flatpak remote-add --if-not-exists flathub " + "https://flathub.org/repo/flathub.flatpakrepo" + ) + ) + continue + rpmfusion_repo.append(info.get("address")) + + return None From be739950c43f02ad9254b40c95dbfa592d82344b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 20:39:30 +0800 Subject: [PATCH 032/240] initial commit for #11 --- src/utils/core/apps_install.py | 0 src/utils/core/apps_uninstall.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/apps_install.py create mode 100644 src/utils/core/apps_uninstall.py diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py new file mode 100644 index 0000000..e69de29 From 24f06565a8105bb50745573d8d18f9e2e2912890 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 20:42:16 +0800 Subject: [PATCH 033/240] use json instead of python dataclasses easier for contributions and user modification --- config/app_for_install.json | 0 config/app_for_removal.json | 0 config/ostree_setup.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 config/app_for_install.json create mode 100644 config/app_for_removal.json create mode 100644 config/ostree_setup.json diff --git a/config/app_for_install.json b/config/app_for_install.json new file mode 100644 index 0000000..e69de29 diff --git a/config/app_for_removal.json b/config/app_for_removal.json new file mode 100644 index 0000000..e69de29 diff --git a/config/ostree_setup.json b/config/ostree_setup.json new file mode 100644 index 0000000..e69de29 From 8abde033354a1d1bd877dd49116b6d4c82bfd513 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 20:43:57 +0800 Subject: [PATCH 034/240] move the list of apps for install in app_for_install.json the json file contains a dictionary of key-value pair containing - name of the application which is the key for another dictionary that contains - aid which is a key for application id of the corresponding program - simple_description which is a simplified description of the program --- config/app_for_install.json | 30 ++++++++++++++++++++++++++ src/data/app_for_install.py | 43 ------------------------------------- 2 files changed, 30 insertions(+), 43 deletions(-) delete mode 100755 src/data/app_for_install.py diff --git a/config/app_for_install.json b/config/app_for_install.json index e69de29..bec27b5 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -0,0 +1,30 @@ +{ + "Mailspring": { + "aid": "com.getmailspring.Mailspring", + "simple_description": "A simple email client." + }, + "LibreOffice": { + "aid": "org.libreoffice.LibreOffice", + "simple_description": "Office suite." + }, + "VLC": { + "aid": "org.videolan.VLC", + "simple_description": "Video player." + }, + "Okular": { + "aid": "org.kde.okular", + "simple_description": "A document viewer." + }, + "GIMP": { + "aid": "org.gimp.GIMP", + "simple_description": "Photo editing application." + }, + "ClamTk": { + "aid": "com.gitlab.davem.ClamTk", + "simple_description": "Front end for ClamAV." + }, + "FlatSeal": { + "aid": "com.github.tchx84.Flatseal", + "simple_description": "GUI for managing flatpak applications permission" + } +} diff --git a/src/data/app_for_install.py b/src/data/app_for_install.py deleted file mode 100755 index f13750a..0000000 --- a/src/data/app_for_install.py +++ /dev/null @@ -1,43 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class GetApps: - """Apps to be installed""" - - #* takes the name of the app, then a dictionary which includes the - #* application id, and then a simple description for the given app - recommend_list: dict[str, dict[str, str]] = { - "Mailspring": { - "aid": "com.getmailspring.Mailspring", - "simple_description": "A simple email client." - }, - "LibreOffice": { - "aid": "org.libreoffice.LibreOffice", - "simple_description": "Office suite." - }, - "VLC": { - "aid": "org.videolan.VLC", - "simple_description": "Video player." - }, - "Okular": { - "aid": "org.kde.okular", - "simple_description": "A document viewer." - }, - "GIMP": { - "aid": "org.gimp.GIMP", - "simple_description": "Photo editing application." - }, - "ClamTk": { - "aid": "com.gitlab.davem.ClamTk", - "simple_description": "Front end for ClamAV." - }, - "FlatSeal": { - "aid": "com.github.tchx84.Flatseal", - "simple_description": ( - "GUI for managing flatpak" - " applications permission" - ) - } - } - selected_app: list[str] = None From b12cb99c3eedd81634040614175890f27b218be3 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 20:46:06 +0800 Subject: [PATCH 035/240] deprecate data subpackage --- src/data/__init__.py | 0 src/data/unused_apps.py | 24 ------------------------ 2 files changed, 24 deletions(-) delete mode 100755 src/data/__init__.py delete mode 100755 src/data/unused_apps.py diff --git a/src/data/__init__.py b/src/data/__init__.py deleted file mode 100755 index e69de29..0000000 diff --git a/src/data/unused_apps.py b/src/data/unused_apps.py deleted file mode 100755 index eb6d887..0000000 --- a/src/data/unused_apps.py +++ /dev/null @@ -1,24 +0,0 @@ -from dataclasses import dataclass - - -@dataclass(frozen=True) -class UnusedApps: - """List of unused apps""" - - flatpaks_unused_apps: dict[str, str] = { - "calculator": "org.gnome.Calculator", - "calendar": "org.gnome.Calendar", - "characters": "org.gnome.Characters", - "connections": "org.gnome.Connections", - "contacts": "org.gnome.Contacts", - "Document Viewer": "org.gnome.Evince", - "extensions": "org.gnome.Extensions", - "logs": "org.gnome.Logs", - "maps": "org.gnome.Maps", - "text editor": "org.gnome.TextEditor", - "weather": "org.gnome.Weather", - "disk usage analyzer": "org.gnome.baobab", - "clocks": "org.gnome.Clocks", - "image viewer": "org.gnome.eog", - "fonts": "org.gnome.fonts-viewer", - } From a7f5e25d91eec8bdda2d9135f8ef04261cddd62b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 20:46:29 +0800 Subject: [PATCH 036/240] lists of unnecessary preinstalled flatpak applications that can be readily removed --- config/app_for_removal.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/app_for_removal.json b/config/app_for_removal.json index e69de29..0deecb4 100644 --- a/config/app_for_removal.json +++ b/config/app_for_removal.json @@ -0,0 +1,17 @@ +{ + "calculator": "org.gnome.Calculator", + "calendar": "org.gnome.Calendar", + "characters": "org.gnome.Characters", + "connections": "org.gnome.Connections", + "contacts": "org.gnome.Contacts", + "Document Viewer": "org.gnome.Evince", + "extensions": "org.gnome.Extensions", + "logs": "org.gnome.Logs", + "maps": "org.gnome.Maps", + "text editor": "org.gnome.TextEditor", + "weather": "org.gnome.Weather", + "disk usage analyzer": "org.gnome.baobab", + "clocks": "org.gnome.Clocks", + "image viewer": "org.gnome.eog", + "fonts": "org.gnome.fonts-viewer" +} From f034cada38f3dc5f9d1b36f03655c27247f05779 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 21:00:53 +0800 Subject: [PATCH 037/240] append requests 2.28.1 --- REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) diff --git a/REQUIREMENTS b/REQUIREMENTS index 9005c4b..2e6e91f 100755 --- a/REQUIREMENTS +++ b/REQUIREMENTS @@ -1 +1,2 @@ rich==12.6.0 +requests==2.28.1 From 8660ccdeda8e1381cbd142b04f4e7da7047985ae Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 21:04:57 +0800 Subject: [PATCH 038/240] for fetching of config file from github --- src/utils/misc/fetch_config.py | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/utils/misc/fetch_config.py diff --git a/src/utils/misc/fetch_config.py b/src/utils/misc/fetch_config.py new file mode 100644 index 0000000..b8ab386 --- /dev/null +++ b/src/utils/misc/fetch_config.py @@ -0,0 +1,46 @@ +from typing import NoReturn + +from requests import get + +from src.utils.log.logger import Logger + + +def fetch_missing_config( + log: Logger, conf: str, CONF_PATH: str + ) -> None | NoReturn: + """Downloads the original config file from github if not found. + + Args: + log -- instance of Logger + conf -- name of the missing config + CONF_PATH -- path of the config file + """ + + conf_link: str = "" + + trial: int + for trial in range(3): + try: + log.logger( + "I", "Fetching the missing config file from Github." + ) + with get(conf_link, stream=True) as d_file: + with open( + f"{CONF_PATH}/{conf}", "wb" + ) as conf_file: + for chunk in d_file.iter_content(chunk_size=1024): + if chunk: + conf_file.write(chunk) + except (ConnectionError, IOError, PermissionError) as Err: + if trial < 2: + continue + + log.logger( + "E", f"{Err}. Cannot download {conf}, aborting ..." + ) + else: + log.logger("I", f"Sucessfully fetched: {conf}.") + return None + + raise SystemExit + From d91ceae0bd35f4e8969e37802efb59ea0d7b5b6e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 21:05:36 +0800 Subject: [PATCH 039/240] move to conf subsubpackage --- src/utils/conf/__init__.py | 1 + src/utils/{misc => conf}/fetch_config.py | 0 2 files changed, 1 insertion(+) create mode 100644 src/utils/conf/__init__.py rename src/utils/{misc => conf}/fetch_config.py (100%) diff --git a/src/utils/conf/__init__.py b/src/utils/conf/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/utils/conf/__init__.py @@ -0,0 +1 @@ + diff --git a/src/utils/misc/fetch_config.py b/src/utils/conf/fetch_config.py similarity index 100% rename from src/utils/misc/fetch_config.py rename to src/utils/conf/fetch_config.py From acff7beed3180411154017285648301baa758638 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 21:14:09 +0800 Subject: [PATCH 040/240] rename conf to conf_name --- src/utils/conf/fetch_config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index b8ab386..6ece379 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -6,13 +6,13 @@ def fetch_missing_config( - log: Logger, conf: str, CONF_PATH: str + log: Logger, conf_name: str, CONF_PATH: str ) -> None | NoReturn: """Downloads the original config file from github if not found. Args: log -- instance of Logger - conf -- name of the missing config + conf_name -- name of the missing config CONF_PATH -- path of the config file """ @@ -26,7 +26,7 @@ def fetch_missing_config( ) with get(conf_link, stream=True) as d_file: with open( - f"{CONF_PATH}/{conf}", "wb" + f"{CONF_PATH}/{conf_name}", "wb" ) as conf_file: for chunk in d_file.iter_content(chunk_size=1024): if chunk: @@ -36,10 +36,10 @@ def fetch_missing_config( continue log.logger( - "E", f"{Err}. Cannot download {conf}, aborting ..." + "E", f"{Err}. Cannot download {conf_name}, aborting ..." ) else: - log.logger("I", f"Sucessfully fetched: {conf}.") + log.logger("I", f"Sucessfully fetched: {conf_name}.") return None raise SystemExit From 4afb561ef9326e00d26c74ed09662819f0ec47fb Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 21:39:24 +0800 Subject: [PATCH 041/240] for parsing and checking of config file --- src/utils/conf/load_conf.py | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/utils/conf/load_conf.py diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py new file mode 100644 index 0000000..1ed9297 --- /dev/null +++ b/src/utils/conf/load_conf.py @@ -0,0 +1,56 @@ +from os import mkdir +from os.path import isdir, exists +from pathlib import Path +from json import load +from typing import NoReturn + +from src.utils.conf.fetch_config import fetch_missing_config +from src.utils.log.logger import Logger + + +class Conf: + def __init__(self, log: Logger, conf: str) -> None: + self.CONF_PATH: str = f"{Path.home()}/.config/ostree_setup" + self.CONF_LIST: list[str] = [ + "app_for_install", "app_for_removal", "ostree_setup" + ] + + self.log: Logger = log + self.conf: str = conf + + def check_missing(self) -> NoReturn | None: + """Checks the config file if missing or not, if missing fetch the + original config file from the repository.""" + + if isdir(self.CONF_PATH): + try: + mkdir(self.CONF_PATH) + except (PermissionError, OSError) as Err: + self.log.logger( + "E", f"{Err}. Cannot make dir for {self.CONF_PATH}" + ) + raise SystemExit + + conf_name: str + for conf_name in self.CONF_LIST: + if not exists(f"{self.CONF_PATH}/{conf_name}"): + fetch_missing_config(self.log, conf_name, self.CONF_PATH) + + return None + + def load_conf(self) -> list[dict[str, str | dict[str, str]]] | NoReturn: + """Load the config file, append it to list and return the list + containing the values of config file.""" + + try: + parsed_conf: list[dict[str, str | dict[str, str]]] = [] + for conf_name in self.CONF_LIST: + parsed_conf.append(load(f"{self.CONF_PATH}/{conf_name}")) + except (FileNotFoundError, PermissionError) as Err: + self.log.logger( + "I", f"{Err}. Can't open config file, run the program again." + ) + else: + return parsed_conf + + raise SystemExit From e156849123eda43efa3aae0cfe10aba2b186b1ca Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 21:57:02 +0800 Subject: [PATCH 042/240] cleanup and update todo --- ToDo.md | 78 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/ToDo.md b/ToDo.md index d785de4..0fca910 100755 --- a/ToDo.md +++ b/ToDo.md @@ -1,39 +1,46 @@ # To Do -## 1. Ask what GPU -Intel internal: +## 1. GPU driver installation + +Intel: - some drivers missing? Nvidia: -- ask if proprietary or Foss drivers - akmod-nvidia xorg-x11-drv-nvidia -- OR akmod-nvodia xorg-x11-drv-nvidia-cuda - -`printf "sudo rpm-ostree install appname" > ~/bin/rpm-installscript.sh` +- OR akmod-nvodia xorg-x11-drv-nvidia-cuda (for CUDA gpus) +## 2. DE based optimizations -## 2. Ask what DE -Gnome +### Gnome (Silverblue) -- uninstall Firefox rpm +- remove gnome software from autostart -KDE +### KDE (Kinoite) - disable the annoying plopping sound -- ask if to uninstall kmousetool, kmag, firefox rpm -- ask to uninstall Gwenview (its kinda useless but easy to use and currently the only app supporting .jxl files) +- ask to uninstall `kmousetool`, `kmag`, `Gwenview` (its kinda useless but easy to use and currently the only app supporting .jxl files) + +## 3. Setup third party repo + +### flatpak (flathub) -## 3. Setup flathub - remove Fedora flatpak - add flathub repo -- ask to install KDE and Gnome nightly repos +- ask whether to install KDE and Gnome nightly repos + +### RPMFusion +- nonfree +- free +- rpmfusion-nonfree-tainted for `libdvdcss2` -## 4. Install flatpak apps -- lets decide on some apps, and all are installed with asking the user. -- Security stuff like ClamAV and Flatseal should be installed nonetheless, maybe one question "do you use the Terminal for Flatpak and Antivirus tasks? y/n" +## 4. Install recommended flatpak apps + +- For apps refer to #7. +- Security stuff like ClamAV and Flatseal should be installed nonetheless, maybe one question `do you use the Terminal for Flatpak and Antivirus tasks? y/n` ## 5. Configure Snap + - "WARNING: This shoud work, but is still experimental" - Personally I found no app that I needed only on Snap - Maybe we need a startup script that mount-binds /var/home to /home to prevent breakages @@ -41,9 +48,9 @@ KDE - does it automatically add the repo to Discover / GNOME Software? ## 6. Configure settings + - Automatic rpm-ostree and Flatpak updates through integration of [this nice script](https://github.com/tonywalker1/silverblue-update) - enabling Mac-Adress randomization for privacy -- enabling - setting up a nice GRUB theme with asking, external github repo cloned - applying UEFI Firmware updates using a systemd timer ([Fedora Silverblue autoupdates](https://github.com/tonywalker1/silverblue-update) as example of a really nice integration) - theme flatpaks using your set GTK theme @@ -52,33 +59,34 @@ KDE - my laptop always has too high mic volume, so I set it to 40% with a start script, yes/no and volume asked. This is added to the postinstall script, so it can be repeated when sure what volume is wanted. Message "you can replace the mic-value in the postinstall.sh script you find in the "bin" folder." - grub menu has to be shown with 5 seconds to decide. Maybe the timespan can be asked, but if the system crashes, it has to be beginner-friendly to switch back to a previous tree -Enabling hibernation: +## 7. Hibernation: + - This is a big thing, very important, I asked already on ask fedora. - Have to test, if a slight modification of [this solution](https://fedoramagazine.org/hibernation-in-fedora-36-workstation/) works -## 7. Downloading MS Fonts +## 8. Downloading MS Fonts + - this is of course optional - still not working in my script - needs to support at least flatpak apps - ask if also install for rpm apps (different folder, probably not needed) -## 8. Setting up RPMfusion repos -this should be very optional -the rpmfusion-nonfree-tainted repo is needed for libdvdcss2, but VLC and others have it integrated, only handbrake doesnt (created an issue already) -the other repos are pretty unnesscary for normal users, this is to mention - ## 9. Downloading Lynis + - `mkdir ~/bin` (there is a wget option to auto-create missing folders!) - wget https://github.com/CISOfy/lynis/raw/master/lynis -P ~/bin/ - a systemd timer once a week, running only that command. Way better than cloning the whole repo -## 10. Installing rpm-packages +## 10. Installing `rpm-packages` + - NOTIFICATION: "You can do other stuff now, installing takes a while...", best as notification in the tray? - `zenity --info --text="Installing packages...\n\nYou can do other stuff now\." --title="Info\!"` -- TIP: To list available dnf packages, you can enter a toolbox (toolbox create 1 && toolbox enter 1 && dnf list) or layer dnfdragora (sudo rpm-ostree install dnfdragora), as rpm-ostree doesnt support that currently + +- iaacornus: to me it seems better in notification tray? + - Speed: use extra script that is generated using appending the names - As if want to game and use the custom RPM Proton https://github.com/GloriousEggroll/proton-ge-custom or the flatpak one without patches -- sudo rpm-ostree override remove libavcodec-free --install exiftool perl-Image-ExifTool clamtk* fail2ban tlp make gcc-c++ qemu-kvm qemu-img qemu-user-static ffmpegthumbs kffmpegthumbnailer #libfprint unrar stacer pip android-tools btfs +- rpm-ostree override remove libavcodec-free --install exiftool perl-Image-ExifTool clamtk* fail2ban tlp make gcc-c++ qemu-kvm qemu-img qemu-user-static ffmpegthumbs kffmpegthumbnailer #libfprint unrar stacer pip android-tools btfs - optional: install java, perl, not preinstalled `printf "appnamex " >> ~/Fedora-OSTree-setup/rpm-install.sh` @@ -86,6 +94,7 @@ the other repos are pretty unnesscary for normal users, this is to mention at the end of all rpm-package y/n choices, the installscript is executed with sudo ### 10.1 Waydroid + - custom COPR repo! Display a small warning about that - Only works on Wayland! But wayland is still buggy, display that as a message - includes a few more steps, I got most of them ready @@ -93,25 +102,24 @@ at the end of all rpm-package y/n choices, the installscript is executed with su `sed -i `s/#settingname //g` ~/bin/postinstall.sh` -Keyboard +## 11. Keyboard - Layout chooseable after I found a solution where to get the .kml files from - big if elif loop, with 1= en-Qwerty (no changes), 2 = QWERTZ, 3 = ... -Folder-Sync +## 12. Folder-Sync - mount binded folders like Downloads, Pictures and Documents - - take the language from the keyboard language? question if this should be done - - manual: input of user "how is your Pictures folder called?", use that in mount-bind command +- take the language from the keyboard language? question if this should be done +- manual: input of user "how is your Pictures folder called?", use that in mount-bind command +## 13. reboot settings -## 11. reboot settings - the after-install script should be set as autostart script - the rpm-ostree processes took a while, display a window saying "you can reboot your pc now", as a popup window. With a `wait 30` command a reboot is initiated automatically +## 14. Second script after reboot - -## 12. Second script after reboot - inits automatically, but in background! can this be changed? - Waydroid settings - RPM app settings? From 221268dbd517b9a04fd8896612c74334c99c5cb6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 27 Dec 2022 22:00:43 +0800 Subject: [PATCH 043/240] link issue tracker for feature in development --- ToDo.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ToDo.md b/ToDo.md index 0fca910..e36520a 100755 --- a/ToDo.md +++ b/ToDo.md @@ -1,6 +1,6 @@ # To Do -## 1. GPU driver installation +## 1. GPU driver installation ([#5](/../../issues/5)) Intel: - some drivers missing? @@ -9,7 +9,7 @@ Nvidia: - akmod-nvidia xorg-x11-drv-nvidia - OR akmod-nvodia xorg-x11-drv-nvidia-cuda (for CUDA gpus) -## 2. DE based optimizations +## 2. DE based optimizations ([#11](/../../issues/11)) ### Gnome (Silverblue) @@ -20,7 +20,7 @@ Nvidia: - disable the annoying plopping sound - ask to uninstall `kmousetool`, `kmag`, `Gwenview` (its kinda useless but easy to use and currently the only app supporting .jxl files) -## 3. Setup third party repo +## 3. Setup third party repo ([#6](/../../issues/6)) ### flatpak (flathub) @@ -34,9 +34,8 @@ Nvidia: - free - rpmfusion-nonfree-tainted for `libdvdcss2` -## 4. Install recommended flatpak apps +## 4. Install recommended flatpak apps ([#7](/../../issues/7)) -- For apps refer to #7. - Security stuff like ClamAV and Flatseal should be installed nonetheless, maybe one question `do you use the Terminal for Flatpak and Antivirus tasks? y/n` ## 5. Configure Snap From add421e0347bc7e380a88cb4a3ffb1675ec9585d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 29 Dec 2022 21:48:36 +0800 Subject: [PATCH 044/240] include the applications suggestion in #7 --- config/app_for_install.json | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/config/app_for_install.json b/config/app_for_install.json index bec27b5..4bd66e9 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -26,5 +26,57 @@ "FlatSeal": { "aid": "com.github.tchx84.Flatseal", "simple_description": "GUI for managing flatpak applications permission" + }, + "KeepassXC": { + "aid": "org.keepassxc.KeePassXC", + "simple_description": "Secure Password manager." + }, + "Cryptomator": { + "aid": "org.cryptomator.Cryptomator", + "simple_description": "Secure and easy encryption, especially for Cloud storages." + }, + "Easy-Effects": { + "aid": "com.github.wwmm.easyeffects", + "simple_description": "Modify your PulseAudio sound" + }, + "Sync-Thingy": { + "aid": "com.github.zocker_160.SyncThingy", + "simple_description": "Sync folders securely between devices, no server." + }, + "XNView MP": { + "aid": "com.xnview.XnViewMP", + "simple_description": "Image Viewer and editor with many functions" + }, + "Freetube": { + "aid": "io.freetubeapp.FreeTube", + "simple_description": "Watch YouTube privately with local subscriptions and playlists." + }, + "Inkscape": { + "aid": "org.inkscape.Inkscape", + "simple_description": "A Vector graphics program" + }, + "GNOME Boxen": { + "aid": "org.gnome.Boxes", + "simple_description": "Manage fast Virtual machines with a simple interface." + }, + "Filelight": { + "aid": "org.kde.filelight ", + "simple_description": "View what files consume how much space in a pie chart." + }, + "Kdenlive": { + "aid": "org.kde.kdenlive", + "simple_description": "Video cut program" + }, + "Onion Share": { + "aid": "org.onionshare.OnionShare", + "simple_description": "Share files, chat and create websites over Tor" + }, + "qBittorrent": { + "aid": "org.qbittorrent.qBittorrent", + "simple_description": "Share files decentral with a big community." + }, + "Metadata-cleaner": { + "aid": "fr.romainvigier.MetadataCleaner", + "simple_description": "Easily remove all identifying information on Images using exiftool." } } From 9a4f04280f5d89b2377b0a8d4323890f2e3f488e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:25:53 +0800 Subject: [PATCH 045/240] include comment informing about the blank value for conf_link --- src/utils/conf/fetch_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 6ece379..910771a 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -16,7 +16,7 @@ def fetch_missing_config( CONF_PATH -- path of the config file """ - conf_link: str = "" + conf_link: str = "" # link to be added trial: int for trial in range(3): From 33eb107a63f952e4af1b02fbfe2be0004659c1f5 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:29:29 +0800 Subject: [PATCH 046/240] remove unused variable conf --- src/utils/conf/load_conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 1ed9297..55ace05 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -9,14 +9,13 @@ class Conf: - def __init__(self, log: Logger, conf: str) -> None: + def __init__(self, log: Logger) -> None: self.CONF_PATH: str = f"{Path.home()}/.config/ostree_setup" self.CONF_LIST: list[str] = [ "app_for_install", "app_for_removal", "ostree_setup" ] self.log: Logger = log - self.conf: str = conf def check_missing(self) -> NoReturn | None: """Checks the config file if missing or not, if missing fetch the From bd3c623ceaa309b12ec03b3d57d1d365af6ff383 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:48:40 +0800 Subject: [PATCH 047/240] use dictionary to hold the links of different configs --- src/utils/conf/fetch_config.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 910771a..2194125 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -16,7 +16,20 @@ def fetch_missing_config( CONF_PATH -- path of the config file """ - conf_link: str = "" # link to be added + conf_links: dict[str, str] = { + "app_for_install": ( + "https://raw.githubusercontent.com/iaacornus/" + "Fedora-OSTree-Setup/devel/config/app_for_install.json" + ), + "app_for_removal": ( + "https://raw.githubusercontent.com/iaacornus/" + "Fedora-OSTree-Setup/devel/config/app_for_removal.json" + ), + "ostree_setup": ( + "https://raw.githubusercontent.com/iaacornus/" + "Fedora-OSTree-Setup/devel/config/ostree_setup.json" + ) + } trial: int for trial in range(3): From c463817471381b33ab252f329fcbade6a59118e2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:49:15 +0800 Subject: [PATCH 048/240] include \`.json\` in the name of the downloaded config --- src/utils/conf/fetch_config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 2194125..c6a5714 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -37,9 +37,15 @@ def fetch_missing_config( log.logger( "I", "Fetching the missing config file from Github." ) + if not (conf_link := conf_links.get(conf_name, "")): + log.logger( + "E", f"Cannot fetch the config: {conf_name}." + ) + raise SystemExit + with get(conf_link, stream=True) as d_file: with open( - f"{CONF_PATH}/{conf_name}", "wb" + f"{CONF_PATH}/{conf_name}.json", "wb" ) as conf_file: for chunk in d_file.iter_content(chunk_size=1024): if chunk: From 6aa060b7dae0767f4314ef5f58fc41e7977d8a3f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:50:31 +0800 Subject: [PATCH 049/240] fix conditions --- src/utils/conf/load_conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 55ace05..c33d127 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -21,7 +21,7 @@ def check_missing(self) -> NoReturn | None: """Checks the config file if missing or not, if missing fetch the original config file from the repository.""" - if isdir(self.CONF_PATH): + if not isdir(self.CONF_PATH): try: mkdir(self.CONF_PATH) except (PermissionError, OSError) as Err: @@ -32,7 +32,7 @@ def check_missing(self) -> NoReturn | None: conf_name: str for conf_name in self.CONF_LIST: - if not exists(f"{self.CONF_PATH}/{conf_name}"): + if not exists(f"{self.CONF_PATH}/{conf_name}.json"): fetch_missing_config(self.log, conf_name, self.CONF_PATH) return None From 9ca7ca12313de648cbff4bcae8f2673d42a14dd6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:51:07 +0800 Subject: [PATCH 050/240] fix bug the file should be opened first with context manager in read mode before can be included as argument in json.load() --- src/utils/conf/load_conf.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index c33d127..875d9f3 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -44,7 +44,14 @@ def load_conf(self) -> list[dict[str, str | dict[str, str]]] | NoReturn: try: parsed_conf: list[dict[str, str | dict[str, str]]] = [] for conf_name in self.CONF_LIST: - parsed_conf.append(load(f"{self.CONF_PATH}/{conf_name}")) + with open( + f"{self.CONF_PATH}/{conf_name}.json", + "r", + encoding="utf-8" + ) as t_conf: + parsed_conf.append( + load(t_conf) + ) except (FileNotFoundError, PermissionError) as Err: self.log.logger( "I", f"{Err}. Can't open config file, run the program again." From d0a2af9bd2f307b665dcbab24ecc1926e2e23cdf Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:53:17 +0800 Subject: [PATCH 051/240] include documentation for the conf class --- src/utils/conf/load_conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 875d9f3..4a4dd32 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -9,6 +9,8 @@ class Conf: + """For parsing of the config file as well as checking.""" + def __init__(self, log: Logger) -> None: self.CONF_PATH: str = f"{Path.home()}/.config/ostree_setup" self.CONF_LIST: list[str] = [ From 94609958f84b45e7f5d2b76bcb30f855a4b20959 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 00:56:31 +0800 Subject: [PATCH 052/240] initial commit in cli of program --- src/interface/cli.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/interface/cli.py b/src/interface/cli.py index e69de29..bc77720 100755 --- a/src/interface/cli.py +++ b/src/interface/cli.py @@ -0,0 +1,19 @@ +from argparse import ArgumentParser + +from src.utils.log.logger import Logger + +class Cli: + """Commandline interface of the program.""" + + def __init__(self) -> None: + self.log: Logger = Logger() + + self.parser: ArgumentParser = ArgumentParser( + prog="ostree-setup", + usage="ostree-setup [ARGUMENTS]", + description=( + "A small program making the install of Fedora " + "Silverblue / Kionite easy. It lets you choose " + "what to install or set. " + ) + ) From 6e0f3303bbef056c9da3c8ac46957ee86ce13191 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 01:07:28 +0800 Subject: [PATCH 053/240] initial commit for uninstallation of preinstalled apps #11 --- src/utils/core/apps_uninstall.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index e69de29..8012d78 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -0,0 +1,32 @@ +from subprocess import Popopen, CalledProcessError, DEVNULL + +from src.utils.log.logger import Logger + + +def uninstall_apps(log: Logger, app_list: list[str]) -> None: + """Uninstall preinstalled flatpak applications. + + Args: + log -- instance of Logger + app_list -- list of apps to uninstall + """ + + app: str + for app in app_list: + try: + uninstall_cmd: list[str] = [ + "flatpak", + "uninstall", + app, + "--delete-data", + "--system", + "--assumeyes" + ] + command: int = Popopen(uninstall_cmd) + + if command.returncode != 0: + raise CalledProcessError( + command.returncode, uninstall_cmd + ) + except (CalledProcessError) as Err: + log.logger("e", f"{Err}. Can't uninstall {app}, skipping.") From 6befbd4de285752697d8a78cea37d5b291164e3f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 31 Dec 2022 01:10:47 +0800 Subject: [PATCH 054/240] replaced old cold to use execute_command() form src.utils.shared.exec --- src/utils/core/apps_uninstall.py | 34 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 8012d78..1e6e33a 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -1,32 +1,30 @@ -from subprocess import Popopen, CalledProcessError, DEVNULL +from typing import NoReturn +from src.utils.shared.exec import execute_command from src.utils.log.logger import Logger -def uninstall_apps(log: Logger, app_list: list[str]) -> None: +def uninstall_apps( + log: Logger, app_list: list[str], verbose: bool = False + ) -> None | NoReturn: """Uninstall preinstalled flatpak applications. Args: log -- instance of Logger app_list -- list of apps to uninstall + verbose -- whether to show command output or not """ app: str for app in app_list: - try: - uninstall_cmd: list[str] = [ - "flatpak", - "uninstall", - app, - "--delete-data", - "--system", - "--assumeyes" - ] - command: int = Popopen(uninstall_cmd) + uninstall_cmd: list[str] = [ + "flatpak", + "uninstall", + app, + "--delete-data", + "--system", + "--assumeyes" + ] + execute_command(log, uninstall_cmd, verbose) - if command.returncode != 0: - raise CalledProcessError( - command.returncode, uninstall_cmd - ) - except (CalledProcessError) as Err: - log.logger("e", f"{Err}. Can't uninstall {app}, skipping.") + return None From a2b7667e7fd253137831a541b1a417e74574592f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 20:37:08 +0800 Subject: [PATCH 055/240] include break_proc parameter to avoid raising systemexit by default --- src/utils/shared/exec.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index 92244fc..b37584e 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -6,7 +6,10 @@ def execute_command( - log: Logger, command: list[str], verbose: bool = False + log: Logger, + command: list[str], + verbose: bool = False, + break_proc: bool = False ) -> NoReturn | None: """For command execution/system calls with error handling @@ -39,9 +42,11 @@ def execute_command( "E", ( f"{Err} encountered, cannot execute" - " command: {command}, aborting ..." + " command: {command} ..." ) ) - raise SystemExit + + if break_proc: + raise SystemExit return None From b815586ab23e4701e235cfa30becf0820f7303e5 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 20:37:34 +0800 Subject: [PATCH 056/240] update parameter and arguments --- src/utils/core/apps_uninstall.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 1e6e33a..2dc4b6c 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -5,7 +5,10 @@ def uninstall_apps( - log: Logger, app_list: list[str], verbose: bool = False + log: Logger, + app_list: list[str], + verbose: bool = False, + break_proc: bool = False ) -> None | NoReturn: """Uninstall preinstalled flatpak applications. @@ -25,6 +28,6 @@ def uninstall_apps( "--system", "--assumeyes" ] - execute_command(log, uninstall_cmd, verbose) + execute_command(log, uninstall_cmd, verbose, break_proc) return None From 868c4a78d051768d27bb360ad3649cf995846718 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 20:38:07 +0800 Subject: [PATCH 057/240] update function documentation --- src/utils/core/apps_uninstall.py | 1 + src/utils/shared/exec.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 2dc4b6c..af45fd5 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -16,6 +16,7 @@ def uninstall_apps( log -- instance of Logger app_list -- list of apps to uninstall verbose -- whether to show command output or not + break_proc -- whether to raise systemexit or not """ app: str diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index b37584e..1f4cf73 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -16,6 +16,8 @@ def execute_command( Args: log -- Logger instance command -- command to execute with arguments + verbose -- whether to show command output or not + break_proc -- whether to raise systemexit or not Returns: None or raise system exit From dcc5e070e444f67c909829284cfe1dcd417d9cf5 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 20:38:36 +0800 Subject: [PATCH 058/240] remove no return annotation --- src/utils/core/apps_uninstall.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index af45fd5..5b38dae 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -1,5 +1,3 @@ -from typing import NoReturn - from src.utils.shared.exec import execute_command from src.utils.log.logger import Logger @@ -9,7 +7,7 @@ def uninstall_apps( app_list: list[str], verbose: bool = False, break_proc: bool = False - ) -> None | NoReturn: + ) -> None: """Uninstall preinstalled flatpak applications. Args: From c2f6af9d4c1287608523b0725b72e94743c623f3 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 20:42:18 +0800 Subject: [PATCH 059/240] include --explicit-package-bases argument to mypy --- check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check.sh b/check.sh index 7222a1e..7dad664 100755 --- a/check.sh +++ b/check.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -mypy --strict $(git ls-files "*.py") +mypy --strict $(git ls-files "*.py") --explicit-package-base From 3d720893c54c46c3105efc6be2b2ec4299850f8e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 20:43:14 +0800 Subject: [PATCH 060/240] rename into -> repo in for loop --- src/utils/core/third_repo_install.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/third_repo_install.py index 9089417..f9caf37 100644 --- a/src/utils/core/third_repo_install.py +++ b/src/utils/core/third_repo_install.py @@ -44,11 +44,11 @@ def third_repo_install( } } - for info in tp_repo.values(): + for repo in tp_repo.values(): if uinput( - console, f"Install {info.get('name')} ({info.get('desc')})", 1 + console, f"Install {repo.get('name')} ({repo.get('desc')})", 1 ): - if info.get("name").lower() == "flathub": + if repo.get("name").lower() == "flathub": commands.append( ( "flatpak remote-add --if-not-exists flathub " @@ -56,6 +56,6 @@ def third_repo_install( ) ) continue - rpmfusion_repo.append(info.get("address")) + rpmfusion_repo.append(repo.get("address")) return None From 4ef1c12118896e4636ea2d4de0f41d9e9f2108bb Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:06:56 +0800 Subject: [PATCH 061/240] include mypy --install-types --- check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/check.sh b/check.sh index 7dad664..6d61b04 100755 --- a/check.sh +++ b/check.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash +mypy --install-types mypy --strict $(git ls-files "*.py") --explicit-package-base From cd7d3ec709de42dfefe7e1b4259b0651a2dc4fd6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:07:01 +0800 Subject: [PATCH 062/240] fix mypy errors --- src/utils/core/gpu_install.py | 14 ++++++++------ src/utils/core/third_repo_install.py | 6 ++++-- src/utils/shared/exec.py | 2 +- src/utils/shared/fetch_env.py | 7 ++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index b246a49..b13d316 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -4,11 +4,12 @@ PIPE, check_output ) +from typing import Optional from src.utils.log.logger import Logger -def fetch_gpu(log: Logger) -> list[str] | None: +def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: """Fetch the GPU of the system. Args: @@ -20,7 +21,7 @@ def fetch_gpu(log: Logger) -> list[str] | None: try: lspci_out = Popen(("lspci"), stdout=PIPE) - gpu_name: str = check_output( + gpu_name: bytes = check_output( ["grep", "-i", "VGA"], stdin=lspci_out.stdout ) lspci_out.wait() @@ -58,9 +59,9 @@ def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: #! BUT NOT IN DEFAULT OPTIONS, DO IT IN YOUR OWN DISCRETION - gpu_list: list[str] | None = fetch_gpu(log) + gpu_list: Optional[list[list[str]]] = fetch_gpu(log) - if gpu is None: + if not gpu_list: log.logger( "I", "There is no GPU driver to install, skipping ..." ) @@ -70,11 +71,12 @@ def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: "nvidia": ["akmod-nvidia", "xorg-x11-drv-nvidia"], } + gpu: list[str] for gpu in gpu_list: - vendor: str; gpu_info: list[str] | str + vendor: str; gpu_info: list[str] vendor, *gpu_info = gpu - match [vendor, gpu_info]: + match [vendor, *gpu_info]: case ["nvidia", *gpu_info]: drv_id: str = "nvidia" case ["intel", *gpu_info]: diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/third_repo_install.py index f9caf37..56217f6 100644 --- a/src/utils/core/third_repo_install.py +++ b/src/utils/core/third_repo_install.py @@ -1,3 +1,5 @@ +from typing import Any + from rich.console import Console from src.utils.misc.uinput import uinput @@ -6,7 +8,7 @@ def third_repo_install( console: Console, commands: list[str], - rpmfusion_repo: list[str] + rpmfusion_repo: list[Any] ) -> None: """Install third party repositories. @@ -48,7 +50,7 @@ def third_repo_install( if uinput( console, f"Install {repo.get('name')} ({repo.get('desc')})", 1 ): - if repo.get("name").lower() == "flathub": + if repo.get("name") == "flathub": commands.append( ( "flatpak remote-add --if-not-exists flathub " diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index 1f4cf73..28da3f0 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -33,7 +33,7 @@ def execute_command( if verbose: return_code: int = run(command).returncode else: - return_code: int = run(command, stdout=DEVNULL).returncode + return_code = run(command, stdout=DEVNULL).returncode if return_code != 0: raise CalledProcessError(return_code, command) diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py index a447753..8992039 100755 --- a/src/utils/shared/fetch_env.py +++ b/src/utils/shared/fetch_env.py @@ -1,4 +1,5 @@ from os import getenv +from typing import Optional from rich.console import Console @@ -6,7 +7,7 @@ from src.utils.log.logger import Logger -def fetch_env(log: Logger, console: Console, env_var: str) -> str: +def fetch_env(log: Logger, console: Console, env_var: str) -> Optional[str]: """Fetch the value of given env variable. Args: @@ -18,11 +19,11 @@ def fetch_env(log: Logger, console: Console, env_var: str) -> str: """ try: - env_value: str = getenv(env_var.upper()) + env_value: Optional[str] = getenv(env_var.upper()) except OSError as Err: log.logger("e", f"{Err}. No value found for {env_var}.") env_value = uinput( - console, f"Kindly input the value for {env_var}" + console, f"Kindly input the value for {env_var}", 3 ) return env_value From fb95f99358ca6f7bd012388ecf61fb4e978cc361 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:09:09 +0800 Subject: [PATCH 063/240] update mypy version to 0.991 --- DEV_REQUIREMENTS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEV_REQUIREMENTS b/DEV_REQUIREMENTS index 2e62f66..3595091 100755 --- a/DEV_REQUIREMENTS +++ b/DEV_REQUIREMENTS @@ -1 +1 @@ -mypy==0.971 +mypy==0.991 From ee1a8ae99954007d44802329ba2cd8c5df51fc82 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:10:04 +0800 Subject: [PATCH 064/240] github workflow --- .github/workflows/pytest.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 .github/workflows/pytest.yaml diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml new file mode 100755 index 0000000..a2df369 --- /dev/null +++ b/.github/workflows/pytest.yaml @@ -0,0 +1,33 @@ +name: Unittest + +on: + push: + branches: [ "devel" ] + pull_request: + branches: [ "main", "devel" ] + + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install mypy==0.991 + if [ -f REQUIREMENTS ]; then pip install -r REQUIREMENTS; fi + mypy --install-types + - name: Run mypy type check + run: | + mypy --strict $(git ls-files "*.py") --explicit-package-base + working-directory: . From d59662409a98e1ad881c89747cd7f25789913432 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:10:47 +0800 Subject: [PATCH 065/240] rename workflow to mypy type check --- .github/workflows/pytest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index a2df369..1afb365 100755 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -1,4 +1,4 @@ -name: Unittest +name: MYPY TYPE CHECK on: push: From 847d1ce4d4b4ef2d59a33ce460121b7ac400c4fe Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:15:10 +0800 Subject: [PATCH 066/240] include types for requests==2.28 --- DEV_REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) diff --git a/DEV_REQUIREMENTS b/DEV_REQUIREMENTS index 3595091..95ebfdf 100755 --- a/DEV_REQUIREMENTS +++ b/DEV_REQUIREMENTS @@ -1 +1,2 @@ mypy==0.991 +types-requests==2.28.11.7 From edfe6e9266dcc19a2efcdee8236ba0a28c97cbdc Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:15:23 +0800 Subject: [PATCH 067/240] manually install the types instead of mypy --install-types --- .github/workflows/pytest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 1afb365..25761f6 100755 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -26,7 +26,7 @@ jobs: python -m pip install --upgrade pip python -m pip install mypy==0.991 if [ -f REQUIREMENTS ]; then pip install -r REQUIREMENTS; fi - mypy --install-types + if [ -f DEV_REQUIREMENTS ]; then pip install -r DEV_REQUIREMENTS; fi - name: Run mypy type check run: | mypy --strict $(git ls-files "*.py") --explicit-package-base From cd3cdf6ce4e9a01abcac9b35a87239c758100eab Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:22:02 +0800 Subject: [PATCH 068/240] rename simple_description -> sdesc --- config/app_for_install.json | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 4bd66e9..f2db2f1 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -1,82 +1,82 @@ { "Mailspring": { "aid": "com.getmailspring.Mailspring", - "simple_description": "A simple email client." + "sdesc": "A simple email client." }, "LibreOffice": { "aid": "org.libreoffice.LibreOffice", - "simple_description": "Office suite." + "sdesc": "Office suite." }, "VLC": { "aid": "org.videolan.VLC", - "simple_description": "Video player." + "sdesc": "Video player." }, "Okular": { "aid": "org.kde.okular", - "simple_description": "A document viewer." + "sdesc": "A document viewer." }, "GIMP": { "aid": "org.gimp.GIMP", - "simple_description": "Photo editing application." + "sdesc": "Photo editing application." }, "ClamTk": { "aid": "com.gitlab.davem.ClamTk", - "simple_description": "Front end for ClamAV." + "sdesc": "Front end for ClamAV." }, "FlatSeal": { "aid": "com.github.tchx84.Flatseal", - "simple_description": "GUI for managing flatpak applications permission" + "sdesc": "GUI for managing flatpak applications permission" }, "KeepassXC": { "aid": "org.keepassxc.KeePassXC", - "simple_description": "Secure Password manager." + "sdesc": "Secure Password manager." }, "Cryptomator": { "aid": "org.cryptomator.Cryptomator", - "simple_description": "Secure and easy encryption, especially for Cloud storages." + "sdesc": "Secure and easy encryption, especially for Cloud storages." }, "Easy-Effects": { "aid": "com.github.wwmm.easyeffects", - "simple_description": "Modify your PulseAudio sound" + "sdesc": "Modify your PulseAudio sound" }, "Sync-Thingy": { "aid": "com.github.zocker_160.SyncThingy", - "simple_description": "Sync folders securely between devices, no server." + "sdesc": "Sync folders securely between devices, no server." }, "XNView MP": { "aid": "com.xnview.XnViewMP", - "simple_description": "Image Viewer and editor with many functions" + "sdesc": "Image Viewer and editor with many functions" }, "Freetube": { "aid": "io.freetubeapp.FreeTube", - "simple_description": "Watch YouTube privately with local subscriptions and playlists." + "sdesc": "Watch YouTube privately with local subscriptions and playlists." }, "Inkscape": { "aid": "org.inkscape.Inkscape", - "simple_description": "A Vector graphics program" + "sdesc": "A Vector graphics program" }, "GNOME Boxen": { "aid": "org.gnome.Boxes", - "simple_description": "Manage fast Virtual machines with a simple interface." + "sdesc": "Manage fast Virtual machines with a simple interface." }, "Filelight": { "aid": "org.kde.filelight ", - "simple_description": "View what files consume how much space in a pie chart." + "sdesc": "View what files consume how much space in a pie chart." }, "Kdenlive": { "aid": "org.kde.kdenlive", - "simple_description": "Video cut program" + "sdesc": "Video cut program" }, "Onion Share": { "aid": "org.onionshare.OnionShare", - "simple_description": "Share files, chat and create websites over Tor" + "sdesc": "Share files, chat and create websites over Tor" }, "qBittorrent": { "aid": "org.qbittorrent.qBittorrent", - "simple_description": "Share files decentral with a big community." + "sdesc": "Share files decentral with a big community." }, "Metadata-cleaner": { "aid": "fr.romainvigier.MetadataCleaner", - "simple_description": "Easily remove all identifying information on Images using exiftool." + "sdesc": "Easily remove all identifying information on Images using exiftool." } } From 9a433c51b1c49a34b310a24a5e492f346cdefe34 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:23:20 +0800 Subject: [PATCH 069/240] use list instead of dictionary for lists of flatpak apps to uninstall --- config/app_for_removal.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/app_for_removal.json b/config/app_for_removal.json index 0deecb4..05f70c9 100644 --- a/config/app_for_removal.json +++ b/config/app_for_removal.json @@ -1,17 +1,17 @@ -{ - "calculator": "org.gnome.Calculator", - "calendar": "org.gnome.Calendar", - "characters": "org.gnome.Characters", - "connections": "org.gnome.Connections", - "contacts": "org.gnome.Contacts", - "Document Viewer": "org.gnome.Evince", - "extensions": "org.gnome.Extensions", - "logs": "org.gnome.Logs", - "maps": "org.gnome.Maps", - "text editor": "org.gnome.TextEditor", - "weather": "org.gnome.Weather", - "disk usage analyzer": "org.gnome.baobab", - "clocks": "org.gnome.Clocks", - "image viewer": "org.gnome.eog", - "fonts": "org.gnome.fonts-viewer" -} +[ + "org.gnome.Calculator", + "org.gnome.Calendar", + "org.gnome.Characters", + "org.gnome.Connections", + "org.gnome.Contacts", + "org.gnome.Evince", + "org.gnome.Extensions", + "org.gnome.Logs", + "org.gnome.Maps", + "org.gnome.TextEditor", + "org.gnome.Weather", + "org.gnome.baobab", + "org.gnome.Clocks", + "org.gnome.eog", + "org.gnome.fonts-viewer" +] From 4d58225b3ce125501ae861b774569d9dd629eacc Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:28:34 +0800 Subject: [PATCH 070/240] restructure utils package uinput is moved inside shared subpackage as well as log subpackage --- src/utils/misc/__init__.py | 0 src/utils/{ => shared}/log/__init__.py | 0 src/utils/{ => shared}/log/logger.py | 0 src/utils/{misc => shared}/uinput.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100755 src/utils/misc/__init__.py rename src/utils/{ => shared}/log/__init__.py (100%) rename src/utils/{ => shared}/log/logger.py (100%) rename src/utils/{misc => shared}/uinput.py (100%) diff --git a/src/utils/misc/__init__.py b/src/utils/misc/__init__.py deleted file mode 100755 index e69de29..0000000 diff --git a/src/utils/log/__init__.py b/src/utils/shared/log/__init__.py similarity index 100% rename from src/utils/log/__init__.py rename to src/utils/shared/log/__init__.py diff --git a/src/utils/log/logger.py b/src/utils/shared/log/logger.py similarity index 100% rename from src/utils/log/logger.py rename to src/utils/shared/log/logger.py diff --git a/src/utils/misc/uinput.py b/src/utils/shared/uinput.py similarity index 100% rename from src/utils/misc/uinput.py rename to src/utils/shared/uinput.py From aa1acb8775b775a05ecf3202cee4b04faf5ba69c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 21:28:43 +0800 Subject: [PATCH 071/240] update imports --- src/interface/cli.py | 2 +- src/utils/conf/fetch_config.py | 2 +- src/utils/conf/load_conf.py | 2 +- src/utils/core/apps_install.py | 17 +++++++++++++++++ src/utils/core/apps_uninstall.py | 2 +- src/utils/core/gpu_install.py | 2 +- src/utils/core/third_repo_install.py | 2 +- src/utils/shared/exec.py | 2 +- src/utils/shared/fetch_env.py | 4 ++-- 9 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/interface/cli.py b/src/interface/cli.py index bc77720..8f0657d 100755 --- a/src/interface/cli.py +++ b/src/interface/cli.py @@ -1,6 +1,6 @@ from argparse import ArgumentParser -from src.utils.log.logger import Logger +from src.utils.shared.log.logger import Logger class Cli: """Commandline interface of the program.""" diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index c6a5714..21ccb13 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -2,7 +2,7 @@ from requests import get -from src.utils.log.logger import Logger +from src.utils.shared.log.logger import Logger def fetch_missing_config( diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 4a4dd32..119e4bc 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -5,7 +5,7 @@ from typing import NoReturn from src.utils.conf.fetch_config import fetch_missing_config -from src.utils.log.logger import Logger +from src.utils.shared.log.logger import Logger class Conf: diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index e69de29..3d2df31 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -0,0 +1,17 @@ +from src.utils.shared.exec import execute_command +from src.utils.shared.uinput import uinput +from src.utils.shared.log.logger import Logger + + +def app_install( + log: Logger, app_for_install: dict[str, dict[str, str]] + ) -> None: + """For installation of recommended applications selected by the user. + + Args: + log -- instance of Logger + app_for_install -- lists of the recommended applications including + their application id (aid) and description + """ + + pass diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 5b38dae..3cd2e7f 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -1,5 +1,5 @@ from src.utils.shared.exec import execute_command -from src.utils.log.logger import Logger +from src.utils.shared.log.logger import Logger def uninstall_apps( diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index b13d316..2c59189 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -6,7 +6,7 @@ ) from typing import Optional -from src.utils.log.logger import Logger +from src.utils.shared.log.logger import Logger def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/third_repo_install.py index 56217f6..c078726 100644 --- a/src/utils/core/third_repo_install.py +++ b/src/utils/core/third_repo_install.py @@ -2,7 +2,7 @@ from rich.console import Console -from src.utils.misc.uinput import uinput +from src.utils.shared.uinput import uinput def third_repo_install( diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index 28da3f0..c401af8 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -2,7 +2,7 @@ from subprocess import run, CalledProcessError, DEVNULL from typing import NoReturn -from src.utils.log.logger import Logger +from src.utils.shared.log.logger import Logger def execute_command( diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py index 8992039..f41b9bd 100755 --- a/src/utils/shared/fetch_env.py +++ b/src/utils/shared/fetch_env.py @@ -3,8 +3,8 @@ from rich.console import Console -from src.utils.misc.uinput import uinput -from src.utils.log.logger import Logger +from src.utils.shared.uinput import uinput +from src.utils.shared.log.logger import Logger def fetch_env(log: Logger, console: Console, env_var: str) -> Optional[str]: From 76df02cdb07dc23e23db6e610b7644fc39631415 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:27:53 +0800 Subject: [PATCH 072/240] for installation of recommended applications --- src/utils/core/apps_install.py | 59 ++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 3d2df31..4d8a8da 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -1,10 +1,18 @@ +from rich.panel import Panel +from rich.align import Align +from rich.text import Text +from rich.console import Console + from src.utils.shared.exec import execute_command from src.utils.shared.uinput import uinput from src.utils.shared.log.logger import Logger def app_install( - log: Logger, app_for_install: dict[str, dict[str, str]] + log: Logger, + console: Console, + app_for_install: dict[str, dict[str, str]], + verbose: bool = False ) -> None: """For installation of recommended applications selected by the user. @@ -14,4 +22,51 @@ def app_install( their application id (aid) and description """ - pass + appindex: dict[int, str] = { + index: aid for index, aid in zip( + range(len(app_for_install.items())), app_for_install.keys() + ) + } + + console.print( + Panel( + Align( + Text( + "Install applications from flathub", + justify="center" + ), + vertical="middle", + align="center" + ), + title="[bold]Recommended Flatpak Applications[/bold]" + ) + ) + + appname: str + for index, appname in appindex.items(): + console.print( + ( + f"[bold cyan]{index:4}[/bold cyan] " + f"[bold]{appname}[/bold] -- " + f"{app_for_install.get(appname).get('sdesc')}" + ) + ) + + selected_app: list[int] = uinput( + console, "Input the number of applications to install", 2 + ) + + aindex: int + for aindex in selected_app: + sapp_id: str = app_for_install.get( + appindex.get(aindex)).get("aid" + ) + install_cmd: list[str] = [ + "flatpak", + "install", + "flatpak", + sapp_id + ] + execute_command(log, install_cmd, verbose) + + return None From f76ae0a1488cee5e78f4d28db784d52a960ed770 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:28:10 +0800 Subject: [PATCH 073/240] modify the return value of case 2 to return list[int] --- src/utils/shared/uinput.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/shared/uinput.py b/src/utils/shared/uinput.py index 5c5c6b4..e9e7529 100755 --- a/src/utils/shared/uinput.py +++ b/src/utils/shared/uinput.py @@ -35,7 +35,8 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: ", separate by comma ','][/bold]" ), end=" " ) - return input() + items: str = input() + return [int(item) for item in items.strip().split(",")] case 3: console.print( ( From f43c2dea0cb92762ced8ab01462edd702ae46bab Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:34:11 +0800 Subject: [PATCH 074/240] for title banner to separate major operations --- src/utils/shared/title_banner.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/utils/shared/title_banner.py diff --git a/src/utils/shared/title_banner.py b/src/utils/shared/title_banner.py new file mode 100644 index 0000000..1ea262b --- /dev/null +++ b/src/utils/shared/title_banner.py @@ -0,0 +1,31 @@ +from typing import Optional + +from rich.console import Console +from rich.panel import Panel +from rich.align import Align +from rich.text import Text + + +def title_banner(banner_text: str, banner_title: Optional[str] = None) -> None: + """For displaying of title in major operation. + + Args: + text -- main text to display + title -- title of the banner + """ + + Console().print( + Panel( + Align( + Text( + banner_text, + justify="center" + ), + vertical="middle", + align="center" + ), + title=f"[bold]{banner_title}[/bold]" + ) + ) + + return None From ee7b48c8c23867e7781ca04f1c935981088b2b9e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:35:42 +0800 Subject: [PATCH 075/240] capitalize the banner text and uppercase the banner title --- src/utils/shared/title_banner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/shared/title_banner.py b/src/utils/shared/title_banner.py index 1ea262b..a6cf511 100644 --- a/src/utils/shared/title_banner.py +++ b/src/utils/shared/title_banner.py @@ -18,13 +18,13 @@ def title_banner(banner_text: str, banner_title: Optional[str] = None) -> None: Panel( Align( Text( - banner_text, + banner_text.capitalize(), justify="center" ), vertical="middle", align="center" ), - title=f"[bold]{banner_title}[/bold]" + title=f"[bold]{banner_title.upper()}[/bold]" ) ) From e7bc6af3a5cec73d9a088bfe225a1f1a04aad8ca Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:35:59 +0800 Subject: [PATCH 076/240] use title banner instead of manual display --- src/utils/core/apps_install.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 4d8a8da..fc55232 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -1,10 +1,8 @@ -from rich.panel import Panel -from rich.align import Align -from rich.text import Text from rich.console import Console from src.utils.shared.exec import execute_command from src.utils.shared.uinput import uinput +from src.utils.shared.title_banner import title_banner from src.utils.shared.log.logger import Logger @@ -28,18 +26,9 @@ def app_install( ) } - console.print( - Panel( - Align( - Text( - "Install applications from flathub", - justify="center" - ), - vertical="middle", - align="center" - ), - title="[bold]Recommended Flatpak Applications[/bold]" - ) + title_banner( + "installation of recommended apps", + "recommended apps flatpak" ) appname: str From 9d673b0c88acbf9ea5da6f96a58e203013127219 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:36:49 +0800 Subject: [PATCH 077/240] update function parameter documentation --- src/utils/core/apps_install.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index fc55232..348dbb9 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -18,6 +18,7 @@ def app_install( log -- instance of Logger app_for_install -- lists of the recommended applications including their application id (aid) and description + verbose -- whether to display the process output or not """ appindex: dict[int, str] = { From 31bfabc88f60c3d962783351c8a13011148ff6b9 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:38:41 +0800 Subject: [PATCH 078/240] organize shared subpackage --- src/utils/shared/misc/__init__.py | 0 src/utils/shared/{ => misc}/title_banner.py | 0 src/utils/shared/{ => misc}/uinput.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/shared/misc/__init__.py rename src/utils/shared/{ => misc}/title_banner.py (100%) rename src/utils/shared/{ => misc}/uinput.py (100%) diff --git a/src/utils/shared/misc/__init__.py b/src/utils/shared/misc/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/shared/title_banner.py b/src/utils/shared/misc/title_banner.py similarity index 100% rename from src/utils/shared/title_banner.py rename to src/utils/shared/misc/title_banner.py diff --git a/src/utils/shared/uinput.py b/src/utils/shared/misc/uinput.py similarity index 100% rename from src/utils/shared/uinput.py rename to src/utils/shared/misc/uinput.py From 6cf5a4e171328bec70feee91977f54d43cd7059a Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:38:46 +0800 Subject: [PATCH 079/240] update imports --- src/utils/core/apps_install.py | 4 ++-- src/utils/core/third_repo_install.py | 2 +- src/utils/shared/fetch_env.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 348dbb9..16a4a34 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -1,8 +1,8 @@ from rich.console import Console from src.utils.shared.exec import execute_command -from src.utils.shared.uinput import uinput -from src.utils.shared.title_banner import title_banner +from src.utils.shared.misc.uinput import uinput +from src.utils.shared.misc.title_banner import title_banner from src.utils.shared.log.logger import Logger diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/third_repo_install.py index c078726..1f1af10 100644 --- a/src/utils/core/third_repo_install.py +++ b/src/utils/core/third_repo_install.py @@ -2,7 +2,7 @@ from rich.console import Console -from src.utils.shared.uinput import uinput +from src.utils.shared.misc.uinput import uinput def third_repo_install( diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py index f41b9bd..66ca5d3 100755 --- a/src/utils/shared/fetch_env.py +++ b/src/utils/shared/fetch_env.py @@ -3,7 +3,7 @@ from rich.console import Console -from src.utils.shared.uinput import uinput +from src.utils.shared.misc.uinput import uinput from src.utils.shared.log.logger import Logger From 81040c8c448c393802cea041fc985e40e2cca42b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:39:35 +0800 Subject: [PATCH 080/240] call .strip() method on return of case 3 --- src/utils/shared/misc/uinput.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/shared/misc/uinput.py b/src/utils/shared/misc/uinput.py index e9e7529..286b908 100755 --- a/src/utils/shared/misc/uinput.py +++ b/src/utils/shared/misc/uinput.py @@ -44,6 +44,6 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: ", separate by comma ','][/bold]" ), end=" " ) - return input() + return input().strip() return False From 11a8c5bf05ed6bb98b36408eda858e03a7c89dad Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:40:19 +0800 Subject: [PATCH 081/240] remove unnecessary break_proc parameter --- src/utils/core/apps_uninstall.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 3cd2e7f..45d5b0f 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -6,7 +6,6 @@ def uninstall_apps( log: Logger, app_list: list[str], verbose: bool = False, - break_proc: bool = False ) -> None: """Uninstall preinstalled flatpak applications. @@ -14,7 +13,6 @@ def uninstall_apps( log -- instance of Logger app_list -- list of apps to uninstall verbose -- whether to show command output or not - break_proc -- whether to raise systemexit or not """ app: str @@ -27,6 +25,6 @@ def uninstall_apps( "--system", "--assumeyes" ] - execute_command(log, uninstall_cmd, verbose, break_proc) + execute_command(log, uninstall_cmd, verbose) return None From 3cfa4a1cb608b77360f422cffdf30e182dc33ffd Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:41:38 +0800 Subject: [PATCH 082/240] use list instead of tuple argument in Popen() --- src/utils/core/gpu_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 2c59189..9947d2e 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -20,7 +20,7 @@ def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: """ try: - lspci_out = Popen(("lspci"), stdout=PIPE) + lspci_out = Popen(["lspci"], stdout=PIPE) gpu_name: bytes = check_output( ["grep", "-i", "VGA"], stdin=lspci_out.stdout ) From 916f8dffb7767bf9948bcbfc5a588851cdb3fd21 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 22:55:52 +0800 Subject: [PATCH 083/240] convert to class for easier organization --- src/utils/core/apps_install.py | 133 +++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 49 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 16a4a34..f17da57 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -6,57 +6,92 @@ from src.utils.shared.log.logger import Logger -def app_install( - log: Logger, - console: Console, - app_for_install: dict[str, dict[str, str]], - verbose: bool = False - ) -> None: - """For installation of recommended applications selected by the user. - - Args: - log -- instance of Logger - app_for_install -- lists of the recommended applications including - their application id (aid) and description - verbose -- whether to display the process output or not - """ - - appindex: dict[int, str] = { - index: aid for index, aid in zip( - range(len(app_for_install.items())), app_for_install.keys() - ) - } - - title_banner( - "installation of recommended apps", - "recommended apps flatpak" - ) - - appname: str - for index, appname in appindex.items(): - console.print( - ( - f"[bold cyan]{index:4}[/bold cyan] " - f"[bold]{appname}[/bold] -- " - f"{app_for_install.get(appname).get('sdesc')}" +class AppInstall: + def __init__( + self, + log: Logger, + console: Console, + app_for_install: list[dict[str, dict[str, str]]], + verbose: bool = False + ) -> None: + """ + Args: + log -- instance of Logger + console -- instace of console + app_for_install -- lists of the recommended applications + including their application id (aid) and description + verbose -- whether to display the process output or not + """ + + self.log: Logger = log + self.console: Console = console + self.FLATPAK_APP_LIST: dict[str, dict[str, str]] = app_for_install[0] + self.RPM_APP_LIST: dict[str, dict[str, str]] = app_for_install[1] + self.verbose: bool = verbose + + self.FLATPAK_APP_INDEX: dict[int, str] = { + index: aid for index, aid in zip( + range(len(self.FLATPAK_APP_LIST.items())), + self.FLATPAK_APP_LIST.keys() + ) + } + self.RPM_APP_INDEX: dict[int, str] = { + index: aid for index, aid in zip( + range(len(self.RPM_APP_LIST.items())), + self.RPM_APP_LIST.keys() + ) + } + + def _enum_apps( + self, + app_index: dict[int, str], + app_list: dict[str, dict[str, str]] + ) -> None: + """Enumerate the apps in the list and print out with a format. + + Args: + app_index -- index of applications and their name + app_list -- lists of the recommended applications including + their application id (aid) and description + """ + + appname: str + for index, appname in app_index.items(): + self.console.print( + ( + f"[bold cyan]{index:4}[/bold cyan] " + f"[bold]{appname}[/bold] -- " + f"{app_list.get(appname).get('sdesc')}" + ) ) - ) - selected_app: list[int] = uinput( - console, "Input the number of applications to install", 2 + return None + + def app_install(self) -> None: + """For installation of recommended program selected by user.""" + + title_banner( + "installation of recommended apps", "recommended apps flatpak" ) + self._enum_apps(self.FLATPAK_APP_INDEX, self.FLATPAK_APP_LIST) - aindex: int - for aindex in selected_app: - sapp_id: str = app_for_install.get( - appindex.get(aindex)).get("aid" + selected_app: list[int] = uinput( + self.console, + "Input the number of applications to install", + 2 ) - install_cmd: list[str] = [ - "flatpak", - "install", - "flatpak", - sapp_id - ] - execute_command(log, install_cmd, verbose) - - return None + + aindex: int + for aindex in selected_app: + sapp_id: str = self.APP_LIST.get( + self.FLATPAK_APP_INDEX.get(aindex)).get("aid" + ) + install_cmd: list[str] = [ + "flatpak", + "install", + "flatpak", + sapp_id + ] + execute_command(self.log, install_cmd, self.verbose) + + return None From 62a2ec1924124351a31bdf03490a0c90e5db78d2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 1 Jan 2023 23:03:41 +0800 Subject: [PATCH 084/240] fix mypy errors --- src/utils/core/apps_install.py | 8 ++++---- src/utils/shared/misc/title_banner.py | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index f17da57..325fcd1 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -55,13 +55,13 @@ def _enum_apps( their application id (aid) and description """ - appname: str + index: int; appname: str for index, appname in app_index.items(): self.console.print( ( f"[bold cyan]{index:4}[/bold cyan] " f"[bold]{appname}[/bold] -- " - f"{app_list.get(appname).get('sdesc')}" + f"{app_list.get(appname).get('sdesc')}" # type: ignore ) ) @@ -83,8 +83,8 @@ def app_install(self) -> None: aindex: int for aindex in selected_app: - sapp_id: str = self.APP_LIST.get( - self.FLATPAK_APP_INDEX.get(aindex)).get("aid" + sapp_id: str = self.FLATPAK_APP_LIST.get( # type: ignore + self.FLATPAK_APP_INDEX.get(aindex)).get("aid" # type: ignore ) install_cmd: list[str] = [ "flatpak", diff --git a/src/utils/shared/misc/title_banner.py b/src/utils/shared/misc/title_banner.py index a6cf511..d2f977f 100644 --- a/src/utils/shared/misc/title_banner.py +++ b/src/utils/shared/misc/title_banner.py @@ -1,12 +1,10 @@ -from typing import Optional - from rich.console import Console from rich.panel import Panel from rich.align import Align from rich.text import Text -def title_banner(banner_text: str, banner_title: Optional[str] = None) -> None: +def title_banner(banner_text: str, banner_title: str) -> None: """For displaying of title in major operation. Args: From 51bca2090d546b81f898c4dd57427881d67e013d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:03:21 +0800 Subject: [PATCH 085/240] rename to separate the lists for flatpak and rpm --- config/{app_for_install.json => app_for_install_flatpak.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/{app_for_install.json => app_for_install_flatpak.json} (100%) diff --git a/config/app_for_install.json b/config/app_for_install_flatpak.json similarity index 100% rename from config/app_for_install.json rename to config/app_for_install_flatpak.json From 34281e99b382ccbe5d39b76aa7755b04e46e3ae2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:07:36 +0800 Subject: [PATCH 086/240] specify flatpak in name to avoid getting confused with rpm --- config/{app_for_removal.json => app_for_removal_flatpak.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/{app_for_removal.json => app_for_removal_flatpak.json} (100%) diff --git a/config/app_for_removal.json b/config/app_for_removal_flatpak.json similarity index 100% rename from config/app_for_removal.json rename to config/app_for_removal_flatpak.json From 19a4b65f0e81ac79942f9cb98c0c3c709bee9c9f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:08:07 +0800 Subject: [PATCH 087/240] for installation of recommended rpm applications #13 --- config/app_for_install_rpm.json | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 config/app_for_install_rpm.json diff --git a/config/app_for_install_rpm.json b/config/app_for_install_rpm.json new file mode 100644 index 0000000..691a93f --- /dev/null +++ b/config/app_for_install_rpm.json @@ -0,0 +1,19 @@ +[ + "exiftool", + "perl-Image-ExifTool", + "clamtk*", + "fail2ban", + "tlp", + "make", + "gcc-c++", + "qemu-kvm", + "qemu-img", + "qemu-user-static", + "ffmpegthumbs", + "kffmpegthumbnailer", + "unrar", + "stacer", + "python-pip", + "android-tools", + "btfs" +] From fd60e279316015242a36578a3eaebbca4d7f0c7b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:12:40 +0800 Subject: [PATCH 088/240] removal of some base packages #11 --- config/app_for_removal_rpm.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 config/app_for_removal_rpm.json diff --git a/config/app_for_removal_rpm.json b/config/app_for_removal_rpm.json new file mode 100644 index 0000000..4e11b31 --- /dev/null +++ b/config/app_for_removal_rpm.json @@ -0,0 +1,15 @@ +[ + "libavcodec-free", + "open-vm-tools-desktop", + "open-vm-tools", + "qemu-guest-agent", + "spice-vdagent", + "spice-webdavd", + "virtualbox-guest-additions", + "gnome-shell-extension-apps-menu", + "gnome-classic-session", + "gnome-shell-extension-window-list", + "gnome-shell-extension-background-logo", + "gnome-shell-extension-launch-new-instance", + "gnome-shell-extension-places-menu" +] From 6d3e3f4b6e703772bf8e7ca35c1326c256dbe6b7 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:15:06 +0800 Subject: [PATCH 089/240] use dictionary instead of array has a key-value pair of app-name and another dictionary which contains a key-value pair of app-name: name and sdesc: and the simple description of the corresponding application --- config/app_for_install_rpm.json | 90 ++++++++++++++++++++++++++------- 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/config/app_for_install_rpm.json b/config/app_for_install_rpm.json index 691a93f..813154c 100644 --- a/config/app_for_install_rpm.json +++ b/config/app_for_install_rpm.json @@ -1,19 +1,71 @@ -[ - "exiftool", - "perl-Image-ExifTool", - "clamtk*", - "fail2ban", - "tlp", - "make", - "gcc-c++", - "qemu-kvm", - "qemu-img", - "qemu-user-static", - "ffmpegthumbs", - "kffmpegthumbnailer", - "unrar", - "stacer", - "python-pip", - "android-tools", - "btfs" -] +{ + "exiftool": { + "name": "", + "sdesc": "" + }, + "perl-Image-ExifTool": { + "name": "", + "sdesc": "" + }, + "clamtk*": { + "name": "", + "sdesc": "" + }, + "fail2ban": { + "name": "", + "sdesc": "" + }, + "tlp": { + "name": "", + "sdesc": "" + }, + "make": { + "name": "", + "sdesc": "" + }, + "gcc-c++": { + "name": "", + "sdesc": "" + }, + "qemu-kvm": { + "name": "", + "sdesc": "" + }, + "qemu-img": { + "name": "", + "sdesc": "" + }, + "qemu-user-static": { + "name": "", + "sdesc": "" + }, + "ffmpegthumbs": { + "name": "", + "sdesc": "" + }, + "kffmpegthumbnailer": { + "name": "", + "sdesc": "" + }, + "unrar": { + "name": "", + "sdesc": "" + }, + "stacer": { + "name": "", + "sdesc": "" + }, + "python-pip": { + "name": "", + "sdesc": "" + }, + "android-tools": { + "name": "", + "sdesc": "" + }, + "btfs": { + "name": "", + "sdesc": "" + } +} + From 8cbeb10107a7a599497f99a452b351b0e808dcd7 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:19:16 +0800 Subject: [PATCH 090/240] use dictionary instead of array a dictionary was instead used so that the user can easily review the uses of the application being recommended to be removed, null was used in sdesc since the name of the application suggests it use directly. --- config/app_for_removal_flatpak.json | 79 ++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/config/app_for_removal_flatpak.json b/config/app_for_removal_flatpak.json index 05f70c9..7c459ec 100644 --- a/config/app_for_removal_flatpak.json +++ b/config/app_for_removal_flatpak.json @@ -1,17 +1,62 @@ -[ - "org.gnome.Calculator", - "org.gnome.Calendar", - "org.gnome.Characters", - "org.gnome.Connections", - "org.gnome.Contacts", - "org.gnome.Evince", - "org.gnome.Extensions", - "org.gnome.Logs", - "org.gnome.Maps", - "org.gnome.TextEditor", - "org.gnome.Weather", - "org.gnome.baobab", - "org.gnome.Clocks", - "org.gnome.eog", - "org.gnome.fonts-viewer" -] +{ + "Calculator": { + "aid": "org.gnome.Calculator", + "sdesc": null + }, + "Calendar": { + "aid": "org.gnome.Calendar", + "sdesc": null + }, + "Characters": { + "aid": "org.gnome.Characters", + "sdesc": null + }, + "Connections": { + "aid": "org.gnome.Connections", + "sdesc": null + }, + "Contacts": { + "aid": "org.gnome.Contacts", + "sdesc": null + }, + "Evince": { + "aid": "org.gnome.Evince", + "sdesc": null + }, + "Extensions": { + "aid": "org.gnome.Extensions", + "sdesc": null + }, + "Logs": { + "aid": "org.gnome.Logs", + "sdesc": null + }, + "Maps": { + "aid": "org.gnome.Maps", + "sdesc": null + }, + "Text Editor": { + "aid": "org.gnome.TextEditor", + "sdesc": null + }, + "Weather": { + "aid": "org.gnome.Weather", + "sdesc": null + }, + "Disk Usage Analyzer": { + "aid": "org.gnome.baobab", + "sdesc": null + }, + "Clocks": { + "aid": "org.gnome.Clocks", + "sdesc": null + }, + "Image Viewer": { + "aid": "org.gnome.eog", + "sdesc": null + }, + "Fonts Viewer": { + "aid": "org.gnome.fonts-viewer", + "sdesc": null + } +} From fcf1e7b08af751eefd4b7a8e5096061d8aaf664e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:20:28 +0800 Subject: [PATCH 091/240] removed sdesc completely --- config/app_for_removal_flatpak.json | 45 ++++++++++------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/config/app_for_removal_flatpak.json b/config/app_for_removal_flatpak.json index 7c459ec..96c1c83 100644 --- a/config/app_for_removal_flatpak.json +++ b/config/app_for_removal_flatpak.json @@ -1,62 +1,47 @@ { "Calculator": { - "aid": "org.gnome.Calculator", - "sdesc": null + "aid": "org.gnome.Calculator" }, "Calendar": { - "aid": "org.gnome.Calendar", - "sdesc": null + "aid": "org.gnome.Calendar" }, "Characters": { - "aid": "org.gnome.Characters", - "sdesc": null + "aid": "org.gnome.Characters" }, "Connections": { - "aid": "org.gnome.Connections", - "sdesc": null + "aid": "org.gnome.Connections" }, "Contacts": { - "aid": "org.gnome.Contacts", - "sdesc": null + "aid": "org.gnome.Contacts" }, "Evince": { - "aid": "org.gnome.Evince", - "sdesc": null + "aid": "org.gnome.Evince" }, "Extensions": { - "aid": "org.gnome.Extensions", - "sdesc": null + "aid": "org.gnome.Extensions" }, "Logs": { - "aid": "org.gnome.Logs", - "sdesc": null + "aid": "org.gnome.Logs" }, "Maps": { - "aid": "org.gnome.Maps", - "sdesc": null + "aid": "org.gnome.Maps" }, "Text Editor": { - "aid": "org.gnome.TextEditor", - "sdesc": null + "aid": "org.gnome.TextEditor" }, "Weather": { - "aid": "org.gnome.Weather", - "sdesc": null + "aid": "org.gnome.Weather" }, "Disk Usage Analyzer": { - "aid": "org.gnome.baobab", - "sdesc": null + "aid": "org.gnome.baobab" }, "Clocks": { - "aid": "org.gnome.Clocks", - "sdesc": null + "aid": "org.gnome.Clocks" }, "Image Viewer": { - "aid": "org.gnome.eog", - "sdesc": null + "aid": "org.gnome.eog" }, "Fonts Viewer": { - "aid": "org.gnome.fonts-viewer", - "sdesc": null + "aid": "org.gnome.fonts-viewer" } } From 15557386604cc4c016f05e158284bab2bd371b0c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:21:04 +0800 Subject: [PATCH 092/240] remove aid and simply use a key-value pair of app-name: app id --- config/app_for_removal_flatpak.json | 60 ++++++++--------------------- 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/config/app_for_removal_flatpak.json b/config/app_for_removal_flatpak.json index 96c1c83..ff10521 100644 --- a/config/app_for_removal_flatpak.json +++ b/config/app_for_removal_flatpak.json @@ -1,47 +1,17 @@ { - "Calculator": { - "aid": "org.gnome.Calculator" - }, - "Calendar": { - "aid": "org.gnome.Calendar" - }, - "Characters": { - "aid": "org.gnome.Characters" - }, - "Connections": { - "aid": "org.gnome.Connections" - }, - "Contacts": { - "aid": "org.gnome.Contacts" - }, - "Evince": { - "aid": "org.gnome.Evince" - }, - "Extensions": { - "aid": "org.gnome.Extensions" - }, - "Logs": { - "aid": "org.gnome.Logs" - }, - "Maps": { - "aid": "org.gnome.Maps" - }, - "Text Editor": { - "aid": "org.gnome.TextEditor" - }, - "Weather": { - "aid": "org.gnome.Weather" - }, - "Disk Usage Analyzer": { - "aid": "org.gnome.baobab" - }, - "Clocks": { - "aid": "org.gnome.Clocks" - }, - "Image Viewer": { - "aid": "org.gnome.eog" - }, - "Fonts Viewer": { - "aid": "org.gnome.fonts-viewer" - } + "Calculator": "org.gnome.Calculator", + "Calendar": "org.gnome.Calendar", + "Characters": "org.gnome.Characters", + "Connections": "org.gnome.Connections", + "Contacts": "org.gnome.Contacts", + "Evince": "org.gnome.Evince", + "Extensions": "org.gnome.Extensions", + "Logs": "org.gnome.Logs", + "Maps": "org.gnome.Maps", + "Text Editor": "org.gnome.TextEditor", + "Weather": "org.gnome.Weather", + "Disk Usage Analyzer": "org.gnome.baobab", + "Clocks": "org.gnome.Clocks", + "Image Viewer": "org.gnome.eog", + "Fonts Viewer": "org.gnome.fonts-viewer" } From 7282c73113f3fdb4f355bd70ce7aedb0e31cd506 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:24:17 +0800 Subject: [PATCH 093/240] update links and name of files in config list --- src/utils/conf/fetch_config.py | 24 ++++++++++++++++-------- src/utils/conf/load_conf.py | 6 +++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 21ccb13..fefc8e3 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -17,17 +17,25 @@ def fetch_missing_config( """ conf_links: dict[str, str] = { - "app_for_install": ( - "https://raw.githubusercontent.com/iaacornus/" - "Fedora-OSTree-Setup/devel/config/app_for_install.json" + "app_for_install_flatpak": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_install_flatpak.json" ), - "app_for_removal": ( - "https://raw.githubusercontent.com/iaacornus/" - "Fedora-OSTree-Setup/devel/config/app_for_removal.json" + "app_for_install_rpm": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_install_rpm.json" + ), + "app_for_removal_flatpak": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_removal_flatpak.json" + ), + "app_for_removal_rpm": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_removal_rpm.json" ), "ostree_setup": ( - "https://raw.githubusercontent.com/iaacornus/" - "Fedora-OSTree-Setup/devel/config/ostree_setup.json" + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/ostree_setup.json" ) } diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 119e4bc..183a926 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -14,7 +14,11 @@ class Conf: def __init__(self, log: Logger) -> None: self.CONF_PATH: str = f"{Path.home()}/.config/ostree_setup" self.CONF_LIST: list[str] = [ - "app_for_install", "app_for_removal", "ostree_setup" + "app_for_install_flatpak", + "app_for_install_rpm", + "app_for_removal_flatpak", + "app_for_removal_rpm", + "ostree_setup" ] self.log: Logger = log From 44ff6cb5928fbd4374419d7c4968460a05176e91 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:27:03 +0800 Subject: [PATCH 094/240] rename third_repo_install -> tp_repo_install --- src/utils/core/{third_repo_install.py => tp_repo_install.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/utils/core/{third_repo_install.py => tp_repo_install.py} (98%) diff --git a/src/utils/core/third_repo_install.py b/src/utils/core/tp_repo_install.py similarity index 98% rename from src/utils/core/third_repo_install.py rename to src/utils/core/tp_repo_install.py index 1f1af10..c09fab0 100644 --- a/src/utils/core/third_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -5,7 +5,7 @@ from src.utils.shared.misc.uinput import uinput -def third_repo_install( +def tp_repo_install( console: Console, commands: list[str], rpmfusion_repo: list[Any] From 435eead2efae2b4348db23bfb65480c6149eda00 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:31:18 +0800 Subject: [PATCH 095/240] include gnome-nightly, kde, and fedora oci in third repo installs #6 --- src/utils/core/tp_repo_install.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index c09fab0..3f6b3c6 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -43,6 +43,26 @@ def tp_repo_install( "name": "Flathub", "desc": "Unfiltered repository for flatpaks.", "address": "https://flathub.org/repo/flathub.flatpakrepo" + }, + 4: { + "name": "Fedora OCI", + "desc": "", #? what's this for?, + "address": "oci+https://registry.fedoraproject.org" + }, + 5: { + "name": "KDE", + "desc": "KDE Applications.", + "address": ( + "https://distribute.kde.org/kdeapps.flatpakrepo" + ) + }, + 6: { + "name": "GNOME Nightly", + "desc": "For cutting edge builds from GNOME.", + "address": ( + "https://nightly.gnome.org/" + "gnome-nightly.flatpakrepo" + ) } } From 5bf6340e53763cddbd16548026b0877ee975a022 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 21:48:12 +0800 Subject: [PATCH 096/240] replace capitalize() with upper() --- src/utils/shared/misc/title_banner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/shared/misc/title_banner.py b/src/utils/shared/misc/title_banner.py index d2f977f..f1e16f2 100644 --- a/src/utils/shared/misc/title_banner.py +++ b/src/utils/shared/misc/title_banner.py @@ -16,7 +16,7 @@ def title_banner(banner_text: str, banner_title: str) -> None: Panel( Align( Text( - banner_text.capitalize(), + banner_text.upper(), justify="center" ), vertical="middle", From 09ece42117d80fe0d4d61696f8b4b31cab4f56be Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 3 Jan 2023 22:54:55 +0800 Subject: [PATCH 097/240] remove repititive lines --- src/utils/core/apps_install.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 325fcd1..5fbdf03 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -11,22 +11,25 @@ def __init__( self, log: Logger, console: Console, - app_for_install: list[dict[str, dict[str, str]]], + flatpak_list: dict[str, dict[str, str]], + rpm_list: dict[str, dict[str, str]], verbose: bool = False ) -> None: """ Args: log -- instance of Logger console -- instace of console - app_for_install -- lists of the recommended applications + flatpak_list -- lists of the recommended applications + including their application id (aid) and description + rpm_list -- lists of the recommended applications including their application id (aid) and description verbose -- whether to display the process output or not """ self.log: Logger = log self.console: Console = console - self.FLATPAK_APP_LIST: dict[str, dict[str, str]] = app_for_install[0] - self.RPM_APP_LIST: dict[str, dict[str, str]] = app_for_install[1] + self.FLATPAK_APP_LIST: dict[str, dict[str, str]] = flatpak_list + self.RPM_APP_LIST: dict[str, dict[str, str]] = rpm_list self.verbose: bool = verbose self.FLATPAK_APP_INDEX: dict[int, str] = { @@ -70,10 +73,24 @@ def _enum_apps( def app_install(self) -> None: """For installation of recommended program selected by user.""" - title_banner( - "installation of recommended apps", "recommended apps flatpak" - ) - self._enum_apps(self.FLATPAK_APP_INDEX, self.FLATPAK_APP_LIST) + + for apptype, applist in { + "flatpak": { + "index": self.FLATPAK_APP_INDEX, + "list": self.FLATPAK_APP_LIST + }, + "rpm": { + "index": self.RPM_APP_INDEX, + "list": self.RPM_APP_LIST + } + }.items(): + title_banner( + "installation of recommended apps", + f"recommended apps ({apptype})" + ) + self._enum_apps( + applist.get("index"), applist.get("list") + ) selected_app: list[int] = uinput( self.console, From b29e9f1f65fc8662b23913bc835efe12b3111828 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:19:22 +0800 Subject: [PATCH 098/240] create new type aliases to avoid long and confusing annotations AppData is an alias for dict[str, dict[str, str]] which is a the data from json file, while AppIndex is an alias for dict[int, str], although technically they are new alias. --- src/misc/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/misc/__init__.py diff --git a/src/misc/__init__.py b/src/misc/__init__.py new file mode 100644 index 0000000..96527b1 --- /dev/null +++ b/src/misc/__init__.py @@ -0,0 +1,5 @@ +from typing import NewType + + +AppData = NewType("AppData", dict[str, dict[str, str]]) +AppIndex = NewType("AppIndex", dict[int, str]) From 6a719f1aaa5b79a59a595c4a28c97201f511d843 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:22:40 +0800 Subject: [PATCH 099/240] replace long and confusing annotations with new types --- src/utils/core/apps_install.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 5fbdf03..6a18ffd 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -4,6 +4,8 @@ from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.title_banner import title_banner from src.utils.shared.log.logger import Logger +from src.misc import AppData, AppIndex # type: ignore + class AppInstall: @@ -11,8 +13,8 @@ def __init__( self, log: Logger, console: Console, - flatpak_list: dict[str, dict[str, str]], - rpm_list: dict[str, dict[str, str]], + flatpak_list: AppData, + rpm_list: AppData, verbose: bool = False ) -> None: """ @@ -28,17 +30,17 @@ def __init__( self.log: Logger = log self.console: Console = console - self.FLATPAK_APP_LIST: dict[str, dict[str, str]] = flatpak_list - self.RPM_APP_LIST: dict[str, dict[str, str]] = rpm_list + self.FLATPAK_APP_LIST: AppData = flatpak_list + self.RPM_APP_LIST: AppData = rpm_list self.verbose: bool = verbose - self.FLATPAK_APP_INDEX: dict[int, str] = { + self.FLATPAK_APP_INDEX: AppIndex = { index: aid for index, aid in zip( range(len(self.FLATPAK_APP_LIST.items())), self.FLATPAK_APP_LIST.keys() ) } - self.RPM_APP_INDEX: dict[int, str] = { + self.RPM_APP_INDEX: AppIndex = { index: aid for index, aid in zip( range(len(self.RPM_APP_LIST.items())), self.RPM_APP_LIST.keys() @@ -47,8 +49,8 @@ def __init__( def _enum_apps( self, - app_index: dict[int, str], - app_list: dict[str, dict[str, str]] + app_index: AppIndex, + app_list: AppData ) -> None: """Enumerate the apps in the list and print out with a format. From e523cf6b0c85cda587fc50a9183d6e8eb4f4142f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:23:29 +0800 Subject: [PATCH 100/240] wrong file --- src/misc/__init__.py | 5 ----- src/misc/alias.py | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 src/misc/alias.py diff --git a/src/misc/__init__.py b/src/misc/__init__.py index 96527b1..e69de29 100644 --- a/src/misc/__init__.py +++ b/src/misc/__init__.py @@ -1,5 +0,0 @@ -from typing import NewType - - -AppData = NewType("AppData", dict[str, dict[str, str]]) -AppIndex = NewType("AppIndex", dict[int, str]) diff --git a/src/misc/alias.py b/src/misc/alias.py new file mode 100644 index 0000000..96527b1 --- /dev/null +++ b/src/misc/alias.py @@ -0,0 +1,5 @@ +from typing import NewType + + +AppData = NewType("AppData", dict[str, dict[str, str]]) +AppIndex = NewType("AppIndex", dict[int, str]) From f6df5f2c3ff6ddfd2cfd8032b2daa683771d5353 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:23:43 +0800 Subject: [PATCH 101/240] update imports --- src/utils/core/apps_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 6a18ffd..79827d7 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -4,7 +4,7 @@ from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.title_banner import title_banner from src.utils.shared.log.logger import Logger -from src.misc import AppData, AppIndex # type: ignore +from src.misc.alias import AppData, AppIndex # type: ignore From ff5a33a72cd6f45748340d4fb74665d240d52e32 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:29:11 +0800 Subject: [PATCH 102/240] move the iteration of the appdata in _enum_apps() --- src/utils/core/apps_install.py | 68 ++++++++++++++-------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 79827d7..43974ce 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -50,7 +50,9 @@ def __init__( def _enum_apps( self, app_index: AppIndex, - app_list: AppData + app_list: AppData, + apptype: str, + ) -> None: """Enumerate the apps in the list and print out with a format. @@ -60,6 +62,11 @@ def _enum_apps( their application id (aid) and description """ + title_banner( + "installation of recommended apps", + f"recommended apps ({apptype})" + ) + index: int; appname: str for index, appname in app_index.items(): self.console.print( @@ -70,47 +77,26 @@ def _enum_apps( ) ) - return None + return uinput( + self.console, + "Input the number of applications to install", + 2 + ) def app_install(self) -> None: """For installation of recommended program selected by user.""" - - for apptype, applist in { - "flatpak": { - "index": self.FLATPAK_APP_INDEX, - "list": self.FLATPAK_APP_LIST - }, - "rpm": { - "index": self.RPM_APP_INDEX, - "list": self.RPM_APP_LIST - } - }.items(): - title_banner( - "installation of recommended apps", - f"recommended apps ({apptype})" - ) - self._enum_apps( - applist.get("index"), applist.get("list") - ) - - selected_app: list[int] = uinput( - self.console, - "Input the number of applications to install", - 2 - ) - - aindex: int - for aindex in selected_app: - sapp_id: str = self.FLATPAK_APP_LIST.get( # type: ignore - self.FLATPAK_APP_INDEX.get(aindex)).get("aid" # type: ignore - ) - install_cmd: list[str] = [ - "flatpak", - "install", - "flatpak", - sapp_id - ] - execute_command(self.log, install_cmd, self.verbose) - - return None +# aindex: int +# for aindex in selected_app: +# sapp_id: str = self.FLATPAK_APP_LIST.get( # type: ignore +# self.FLATPAK_APP_INDEX.get(aindex)).get("aid" # type: ignore +# ) +# install_cmd: list[str] = [ +# "flatpak", +# "install", +# "flatpak", +# sapp_id +# ] +# execute_command(self.log, install_cmd, self.verbose) +# +# return None From 39cb45673e6c60eeb118c8f08f50d9b9a0296592 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:31:39 +0800 Subject: [PATCH 103/240] create alias instead of new type --- src/misc/alias.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/misc/alias.py b/src/misc/alias.py index 96527b1..67595d6 100644 --- a/src/misc/alias.py +++ b/src/misc/alias.py @@ -1,5 +1,2 @@ -from typing import NewType - - -AppData = NewType("AppData", dict[str, dict[str, str]]) -AppIndex = NewType("AppIndex", dict[int, str]) +AppData = dict[str, dict[str, str]] +AppIndex = dict[int, str] From 508fd93663c5f835d3390ff888d594f8fc9e2a8d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:31:48 +0800 Subject: [PATCH 104/240] update annotations --- src/utils/core/apps_install.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 43974ce..cd4b71b 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -1,10 +1,12 @@ +from typing import Any + from rich.console import Console from src.utils.shared.exec import execute_command from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.title_banner import title_banner from src.utils.shared.log.logger import Logger -from src.misc.alias import AppData, AppIndex # type: ignore +from src.misc.alias import AppData, AppIndex @@ -51,9 +53,8 @@ def _enum_apps( self, app_index: AppIndex, app_list: AppData, - apptype: str, - - ) -> None: + apptype: str + ) -> Any: """Enumerate the apps in the list and print out with a format. Args: From 52ce004c3d01f54b7663f964c4665f2c7ffdb78e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:44:11 +0800 Subject: [PATCH 105/240] use aid instead of name for consistency --- config/app_for_install_rpm.json | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/app_for_install_rpm.json b/config/app_for_install_rpm.json index 813154c..097bcc5 100644 --- a/config/app_for_install_rpm.json +++ b/config/app_for_install_rpm.json @@ -1,70 +1,70 @@ { "exiftool": { - "name": "", + "aid": "", "sdesc": "" }, "perl-Image-ExifTool": { - "name": "", + "aid": "", "sdesc": "" }, "clamtk*": { - "name": "", + "aid": "", "sdesc": "" }, "fail2ban": { - "name": "", + "aid": "", "sdesc": "" }, "tlp": { - "name": "", + "aid": "", "sdesc": "" }, "make": { - "name": "", + "aid": "", "sdesc": "" }, "gcc-c++": { - "name": "", + "aid": "", "sdesc": "" }, "qemu-kvm": { - "name": "", + "aid": "", "sdesc": "" }, "qemu-img": { - "name": "", + "aid": "", "sdesc": "" }, "qemu-user-static": { - "name": "", + "aid": "", "sdesc": "" }, "ffmpegthumbs": { - "name": "", + "aid": "", "sdesc": "" }, "kffmpegthumbnailer": { - "name": "", + "aid": "", "sdesc": "" }, "unrar": { - "name": "", + "aid": "", "sdesc": "" }, "stacer": { - "name": "", + "aid": "", "sdesc": "" }, "python-pip": { - "name": "", + "aid": "", "sdesc": "" }, "android-tools": { - "name": "", + "aid": "", "sdesc": "" }, "btfs": { - "name": "", + "aid": "", "sdesc": "" } } From 21b38a52691e7c8d3710ceea146764eab14cd549 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:46:22 +0800 Subject: [PATCH 106/240] do separate iteration for flatpak and rpm --- src/utils/core/apps_install.py | 51 ++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index cd4b71b..fad8320 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -17,6 +17,7 @@ def __init__( console: Console, flatpak_list: AppData, rpm_list: AppData, + rpm_install_list: list[str], verbose: bool = False ) -> None: """ @@ -27,6 +28,8 @@ def __init__( including their application id (aid) and description rpm_list -- lists of the recommended applications including their application id (aid) and description + rpm_install_list -- list where the rpm that will be install + is contained verbose -- whether to display the process output or not """ @@ -34,6 +37,7 @@ def __init__( self.console: Console = console self.FLATPAK_APP_LIST: AppData = flatpak_list self.RPM_APP_LIST: AppData = rpm_list + self.rpm_to_install = rpm_install_list self.verbose: bool = verbose self.FLATPAK_APP_INDEX: AppIndex = { @@ -61,6 +65,7 @@ def _enum_apps( app_index -- index of applications and their name app_list -- lists of the recommended applications including their application id (aid) and description + apptype -- type of application, where flatpak or rpm """ title_banner( @@ -84,20 +89,36 @@ def _enum_apps( 2 ) - def app_install(self) -> None: + def app_install(self) -> list[str]: """For installation of recommended program selected by user.""" -# aindex: int -# for aindex in selected_app: -# sapp_id: str = self.FLATPAK_APP_LIST.get( # type: ignore -# self.FLATPAK_APP_INDEX.get(aindex)).get("aid" # type: ignore -# ) -# install_cmd: list[str] = [ -# "flatpak", -# "install", -# "flatpak", -# sapp_id -# ] -# execute_command(self.log, install_cmd, self.verbose) -# -# return None + # fappsindex -> flatpak apps index + # rappsindex -> rpm apps index + fappsindex: int; rappindex: int + + for fappsindex in self._enum_apps( + self.FLATPAK_APP_INDEX, self.FLATPAK_APP_LIST, "flatpak" + ): + fapp_id: str = self.FLATPAK_APP_LIST.get( + self.FLATPAK_APP_INDEX.get(fappsindex) # type: ignore + ).get("aid") + install_cmd: list[str] = [ + "flatpak", + "install", + "flathub", + fapp_id + ] + + execute_command(self.log, install_cmd, self.verbose) + + #* FOR RPM PROGRAM + #* returns the list of name of the selected rpm applications + for rappindex in self._enum_apps( + self.RPM_APP_INDEX, self.RPM_APP_LIST, "rpm" + ): + rapp_id: str = self.RPM_APP_LIST.get( # type: ignore + self.RPM_APP_INDEX.get(rappindex) # type: ignore + ).get("aid") + self.rpm_to_install.append(rapp_id) + + return self.rpm_to_install From e6853d5996456d855c073605b3e2d36923b68864 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:49:27 +0800 Subject: [PATCH 107/240] append the flatpak install command instead --- src/utils/core/apps_install.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index fad8320..4adc297 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -17,6 +17,7 @@ def __init__( console: Console, flatpak_list: AppData, rpm_list: AppData, + flatpak_cmd_list: list[str], rpm_install_list: list[str], verbose: bool = False ) -> None: @@ -37,7 +38,8 @@ def __init__( self.console: Console = console self.FLATPAK_APP_LIST: AppData = flatpak_list self.RPM_APP_LIST: AppData = rpm_list - self.rpm_to_install = rpm_install_list + self.rpm_to_install: list[str] = rpm_install_list + self.flatpak_cmd_list: list[str] = flatpak_cmd_list self.verbose: bool = verbose self.FLATPAK_APP_INDEX: AppIndex = { @@ -89,13 +91,16 @@ def _enum_apps( 2 ) - def app_install(self) -> list[str]: + def app_install(self) -> tuple[list[str], list[str]]: """For installation of recommended program selected by user.""" # fappsindex -> flatpak apps index # rappsindex -> rpm apps index fappsindex: int; rappindex: int + #* FOR FLATPAK PROGRAMS + #* appends the flatpak commands that needs to be executed in + #* flatpak_cmd_list for a single execution of commands for fappsindex in self._enum_apps( self.FLATPAK_APP_INDEX, self.FLATPAK_APP_LIST, "flatpak" ): @@ -109,10 +114,10 @@ def app_install(self) -> list[str]: fapp_id ] - execute_command(self.log, install_cmd, self.verbose) + self.flatpak_cmd_list.append(install_cmd) #* FOR RPM PROGRAM - #* returns the list of name of the selected rpm applications + #* appends the list of name of the selected rpm applications for rappindex in self._enum_apps( self.RPM_APP_INDEX, self.RPM_APP_LIST, "rpm" ): From d60587dff426fcf04164f8754cba55d674666185 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:50:12 +0800 Subject: [PATCH 108/240] include --assumeyes argument in flatpak installation --- src/utils/core/apps_install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 4adc297..ff2a013 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -111,7 +111,8 @@ def app_install(self) -> tuple[list[str], list[str]]: "flatpak", "install", "flathub", - fapp_id + fapp_id, + "--assumeyes" ] self.flatpak_cmd_list.append(install_cmd) From 93436c07b96a771bde9f9f570f4b44f2d1509e7c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:58:28 +0800 Subject: [PATCH 109/240] update links --- src/utils/conf/fetch_config.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index fefc8e3..80af062 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -18,20 +18,21 @@ def fetch_missing_config( conf_links: dict[str, str] = { "app_for_install_flatpak": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_install_flatpak.json" + "https://raw.githubusercontent.com/iaacornus/Fedora" + "-OSTree-Setup/devel/config/app_for_install_flatpak.json" + ), "app_for_install_rpm": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_install_rpm.json" + "https://raw.githubusercontent.com/iaacornus/Fedora" + "-OSTree-Setup/devel/config/app_for_install_rpm.json" ), "app_for_removal_flatpak": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_removal_flatpak.json" + "https://raw.githubusercontent.com/iaacornus/Fedora" + "-OSTree-Setup/devel/config/app_for_removal_flatpak.json" ), "app_for_removal_rpm": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_removal_rpm.json" + "https://raw.githubusercontent.com/iaacornus/Fedora" + "-OSTree-Setup/devel/config/app_for_removal_rpm.json" ), "ostree_setup": ( "https://raw.githubusercontent.com/iaacornus/Fedora-" From 877f34794f1279ead59669485adfab22861c10a0 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 04:59:58 +0800 Subject: [PATCH 110/240] create a more informative log msg --- src/utils/conf/fetch_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 80af062..aaddc2a 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -44,11 +44,11 @@ def fetch_missing_config( for trial in range(3): try: log.logger( - "I", "Fetching the missing config file from Github." + "I", f"Fetching the config file ({conf_name}) from Github." ) - if not (conf_link := conf_links.get(conf_name, "")): + if not (conf_link := conf_links.get(conf_name)): # type: ignore log.logger( - "E", f"Cannot fetch the config: {conf_name}." + "E", f"Cannot fetch the config: {conf_name}, aborting ..." ) raise SystemExit From 40f69e73b723c28140c9127475d3809fe1c582e5 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:02:50 +0800 Subject: [PATCH 111/240] configvalue alias --- src/misc/alias.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/misc/alias.py b/src/misc/alias.py index 67595d6..589a51b 100644 --- a/src/misc/alias.py +++ b/src/misc/alias.py @@ -1,2 +1,3 @@ AppData = dict[str, dict[str, str]] AppIndex = dict[int, str] +ConfigValues = list[list[str] | dict[str, str | dict[str, str]]] From a1e1cb41d8674aec7681b494c75cc88a32e4c435 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:03:48 +0800 Subject: [PATCH 112/240] create a more informative log msg and use type alias --- src/utils/conf/load_conf.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 183a926..d72633a 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -6,6 +6,7 @@ from src.utils.conf.fetch_config import fetch_missing_config from src.utils.shared.log.logger import Logger +from src.misc.alias import ConfigValues class Conf: @@ -32,7 +33,7 @@ def check_missing(self) -> NoReturn | None: mkdir(self.CONF_PATH) except (PermissionError, OSError) as Err: self.log.logger( - "E", f"{Err}. Cannot make dir for {self.CONF_PATH}" + "E", f"{Err}. Cannot make dir: {self.CONF_PATH}" ) raise SystemExit @@ -43,12 +44,12 @@ def check_missing(self) -> NoReturn | None: return None - def load_conf(self) -> list[dict[str, str | dict[str, str]]] | NoReturn: + def load_conf(self) -> ConfigValues | NoReturn: """Load the config file, append it to list and return the list containing the values of config file.""" try: - parsed_conf: list[dict[str, str | dict[str, str]]] = [] + parsed_conf: ConfigValues = [] for conf_name in self.CONF_LIST: with open( f"{self.CONF_PATH}/{conf_name}.json", From af749aaebc63b508304d7fe7cdcb7cf02dc4f0e6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:04:52 +0800 Subject: [PATCH 113/240] include documentation for flatpak_cmd_list --- src/utils/core/apps_install.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index ff2a013..ca35c3f 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -29,6 +29,7 @@ def __init__( including their application id (aid) and description rpm_list -- lists of the recommended applications including their application id (aid) and description + flatpak_cmd_list -- all commands related to flatpak rpm_install_list -- list where the rpm that will be install is contained verbose -- whether to display the process output or not From eee48c4084c83679bbb26f951713d0d04b53c4d6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:08:15 +0800 Subject: [PATCH 114/240] return an array instead of calling exec_cmd function --- src/utils/core/apps_uninstall.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 45d5b0f..7bca0f4 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -1,20 +1,16 @@ -from src.utils.shared.exec import execute_command -from src.utils.shared.log.logger import Logger - - -def uninstall_apps( - log: Logger, - app_list: list[str], - verbose: bool = False, - ) -> None: +def uninstall_apps(app_list: list[str]) -> list[list[str]]: """Uninstall preinstalled flatpak applications. Args: - log -- instance of Logger app_list -- list of apps to uninstall - verbose -- whether to show command output or not + flatpak_cmd_list -- all commands related to flatpak + + Returns: + An array of the appropriate uninstall commands """ + uninstall_cmds: list[list[str]] = [] + app: str for app in app_list: uninstall_cmd: list[str] = [ @@ -25,6 +21,6 @@ def uninstall_apps( "--system", "--assumeyes" ] - execute_command(log, uninstall_cmd, verbose) + uninstall_cmds.append(uninstall_cmd) - return None + return uninstall_cmds From 8add883839bcbc53ef0177bba53806e1948c6e92 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:08:39 +0800 Subject: [PATCH 115/240] rename the command to exec_cmd --- src/utils/shared/exec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index c401af8..d863a72 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -5,7 +5,7 @@ from src.utils.shared.log.logger import Logger -def execute_command( +def exec_cmd( log: Logger, command: list[str], verbose: bool = False, From f4141fe4de7d34d6b723d7d53de79cbaf1d81fe7 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:11:32 +0800 Subject: [PATCH 116/240] avoid taking the true array as parameter to the function use a temporary array that contains everything that should be appended to the original array, the temporary array is then returned and used to extend the original array --- src/utils/core/apps_install.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index ca35c3f..9c772a2 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -2,7 +2,6 @@ from rich.console import Console -from src.utils.shared.exec import execute_command from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.title_banner import title_banner from src.utils.shared.log.logger import Logger @@ -17,8 +16,6 @@ def __init__( console: Console, flatpak_list: AppData, rpm_list: AppData, - flatpak_cmd_list: list[str], - rpm_install_list: list[str], verbose: bool = False ) -> None: """ @@ -29,9 +26,6 @@ def __init__( including their application id (aid) and description rpm_list -- lists of the recommended applications including their application id (aid) and description - flatpak_cmd_list -- all commands related to flatpak - rpm_install_list -- list where the rpm that will be install - is contained verbose -- whether to display the process output or not """ @@ -39,8 +33,6 @@ def __init__( self.console: Console = console self.FLATPAK_APP_LIST: AppData = flatpak_list self.RPM_APP_LIST: AppData = rpm_list - self.rpm_to_install: list[str] = rpm_install_list - self.flatpak_cmd_list: list[str] = flatpak_cmd_list self.verbose: bool = verbose self.FLATPAK_APP_INDEX: AppIndex = { @@ -92,9 +84,12 @@ def _enum_apps( 2 ) - def app_install(self) -> tuple[list[str], list[str]]: + def app_install(self) -> tuple[list[list[str]], list[str]]: """For installation of recommended program selected by user.""" + finstall_cmd: list[list[str]] = [] + rpm_install_arr: list[str] = [] + # fappsindex -> flatpak apps index # rappsindex -> rpm apps index fappsindex: int; rappindex: int @@ -115,8 +110,8 @@ def app_install(self) -> tuple[list[str], list[str]]: fapp_id, "--assumeyes" ] + finstall_cmd.append(install_cmd) - self.flatpak_cmd_list.append(install_cmd) #* FOR RPM PROGRAM #* appends the list of name of the selected rpm applications @@ -126,6 +121,6 @@ def app_install(self) -> tuple[list[str], list[str]]: rapp_id: str = self.RPM_APP_LIST.get( # type: ignore self.RPM_APP_INDEX.get(rappindex) # type: ignore ).get("aid") - self.rpm_to_install.append(rapp_id) + rpm_install_arr.append(rapp_id) - return self.rpm_to_install + return finstall_cmd, rpm_install_arr From e794062dacd0fae81b602639a05160c7f32536b2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:13:26 +0800 Subject: [PATCH 117/240] prefix t_ to temporary for distinction --- src/utils/core/apps_install.py | 10 +++++----- src/utils/core/apps_uninstall.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 9c772a2..fe66a17 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -87,8 +87,8 @@ def _enum_apps( def app_install(self) -> tuple[list[list[str]], list[str]]: """For installation of recommended program selected by user.""" - finstall_cmd: list[list[str]] = [] - rpm_install_arr: list[str] = [] + t_finstall_cmd: list[list[str]] = [] + t_rpm_install_arr: list[str] = [] # fappsindex -> flatpak apps index # rappsindex -> rpm apps index @@ -110,7 +110,7 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: fapp_id, "--assumeyes" ] - finstall_cmd.append(install_cmd) + t_finstall_cmd.append(install_cmd) #* FOR RPM PROGRAM @@ -121,6 +121,6 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: rapp_id: str = self.RPM_APP_LIST.get( # type: ignore self.RPM_APP_INDEX.get(rappindex) # type: ignore ).get("aid") - rpm_install_arr.append(rapp_id) + t_rpm_install_arr.append(rapp_id) - return finstall_cmd, rpm_install_arr + return t_finstall_cmd, t_rpm_install_arr diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 7bca0f4..2d4d3ca 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -9,7 +9,7 @@ def uninstall_apps(app_list: list[str]) -> list[list[str]]: An array of the appropriate uninstall commands """ - uninstall_cmds: list[list[str]] = [] + t_funinstall_cmds: list[list[str]] = [] app: str for app in app_list: @@ -21,6 +21,6 @@ def uninstall_apps(app_list: list[str]) -> list[list[str]]: "--system", "--assumeyes" ] - uninstall_cmds.append(uninstall_cmd) + t_funinstall_cmds.append(uninstall_cmd) - return uninstall_cmds + return t_funinstall_cmds From 530ffec3000fab7043178b2326ea40be0bc22735 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:17:32 +0800 Subject: [PATCH 118/240] rename variables another terminology is used for name instead for more consistency list -> arr app -> prog f prefix refers to flatpak r prefix refers to rpm t_ refers to temporary --- src/misc/alias.py | 4 +-- src/utils/core/apps_install.py | 54 ++++++++++++++++---------------- src/utils/core/apps_uninstall.py | 10 +++--- src/utils/core/gpu_install.py | 6 ++-- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/misc/alias.py b/src/misc/alias.py index 589a51b..ef73b7d 100644 --- a/src/misc/alias.py +++ b/src/misc/alias.py @@ -1,3 +1,3 @@ -AppData = dict[str, dict[str, str]] -AppIndex = dict[int, str] +ProgData = dict[str, dict[str, str]] +ProgIndex = dict[int, str] ConfigValues = list[list[str] | dict[str, str | dict[str, str]]] diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index fe66a17..6c86618 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -5,7 +5,7 @@ from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.title_banner import title_banner from src.utils.shared.log.logger import Logger -from src.misc.alias import AppData, AppIndex +from src.misc.alias import ProgData, ProgIndex @@ -14,8 +14,8 @@ def __init__( self, log: Logger, console: Console, - flatpak_list: AppData, - rpm_list: AppData, + fdata_arr: ProgData, + rdata_arr: ProgData, verbose: bool = False ) -> None: """ @@ -31,34 +31,34 @@ def __init__( self.log: Logger = log self.console: Console = console - self.FLATPAK_APP_LIST: AppData = flatpak_list - self.RPM_APP_LIST: AppData = rpm_list + self.FPROG_ARR: ProgData = fdata_arr + self.RPROG_ARR: ProgData = rdata_arr self.verbose: bool = verbose - self.FLATPAK_APP_INDEX: AppIndex = { + self.FPROG_INDEX: ProgIndex = { index: aid for index, aid in zip( - range(len(self.FLATPAK_APP_LIST.items())), - self.FLATPAK_APP_LIST.keys() + range(len(self.FPROG_ARR.items())), + self.FPROG_ARR.keys() ) } - self.RPM_APP_INDEX: AppIndex = { + self.RPROG_INDEX: ProgIndex = { index: aid for index, aid in zip( - range(len(self.RPM_APP_LIST.items())), - self.RPM_APP_LIST.keys() + range(len(self.RPROG_ARR.items())), + self.RPROG_ARR.keys() ) } def _enum_apps( self, - app_index: AppIndex, - app_list: AppData, + progindex: ProgIndex, + progdata: ProgData, apptype: str ) -> Any: """Enumerate the apps in the list and print out with a format. Args: - app_index -- index of applications and their name - app_list -- lists of the recommended applications including + progindex -- index of applications and their name + progdata -- lists of the recommended applications including their application id (aid) and description apptype -- type of application, where flatpak or rpm """ @@ -69,12 +69,12 @@ def _enum_apps( ) index: int; appname: str - for index, appname in app_index.items(): + for index, appname in progindex.items(): self.console.print( ( f"[bold cyan]{index:4}[/bold cyan] " f"[bold]{appname}[/bold] -- " - f"{app_list.get(appname).get('sdesc')}" # type: ignore + f"{progdata.get(appname).get('sdesc')}" # type: ignore ) ) @@ -90,18 +90,18 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: t_finstall_cmd: list[list[str]] = [] t_rpm_install_arr: list[str] = [] - # fappsindex -> flatpak apps index + # fprog_index -> flatpak apps index # rappsindex -> rpm apps index - fappsindex: int; rappindex: int + fprog_index: int; rprog_index: int #* FOR FLATPAK PROGRAMS #* appends the flatpak commands that needs to be executed in #* flatpak_cmd_list for a single execution of commands - for fappsindex in self._enum_apps( - self.FLATPAK_APP_INDEX, self.FLATPAK_APP_LIST, "flatpak" + for fprog_index in self._enum_apps( + self.FPROG_INDEX, self.FPROG_ARR, "flatpak" ): - fapp_id: str = self.FLATPAK_APP_LIST.get( - self.FLATPAK_APP_INDEX.get(fappsindex) # type: ignore + fapp_id: str = self.FPROG_ARR.get( + self.FPROG_INDEX.get(fprog_index) # type: ignore ).get("aid") install_cmd: list[str] = [ "flatpak", @@ -115,11 +115,11 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: #* FOR RPM PROGRAM #* appends the list of name of the selected rpm applications - for rappindex in self._enum_apps( - self.RPM_APP_INDEX, self.RPM_APP_LIST, "rpm" + for rprog_index in self._enum_apps( + self.RPROG_INDEX, self.RPROG_ARR, "rpm" ): - rapp_id: str = self.RPM_APP_LIST.get( # type: ignore - self.RPM_APP_INDEX.get(rappindex) # type: ignore + rapp_id: str = self.RPROG_ARR.get( # type: ignore + self.RPROG_INDEX.get(rprog_index) # type: ignore ).get("aid") t_rpm_install_arr.append(rapp_id) diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 2d4d3ca..096112a 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -1,8 +1,8 @@ -def uninstall_apps(app_list: list[str]) -> list[list[str]]: +def uninstall_apps(prog_arr: list[str]) -> list[list[str]]: """Uninstall preinstalled flatpak applications. Args: - app_list -- list of apps to uninstall + prog_arr -- list of apps to uninstall flatpak_cmd_list -- all commands related to flatpak Returns: @@ -11,12 +11,12 @@ def uninstall_apps(app_list: list[str]) -> list[list[str]]: t_funinstall_cmds: list[list[str]] = [] - app: str - for app in app_list: + prog: str + for prog in prog_arr: uninstall_cmd: list[str] = [ "flatpak", "uninstall", - app, + prog, "--delete-data", "--system", "--assumeyes" diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 9947d2e..ec16d46 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -59,9 +59,9 @@ def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: #! BUT NOT IN DEFAULT OPTIONS, DO IT IN YOUR OWN DISCRETION - gpu_list: Optional[list[list[str]]] = fetch_gpu(log) + gpu_arr: Optional[list[list[str]]] = fetch_gpu(log) - if not gpu_list: + if not gpu_arr: log.logger( "I", "There is no GPU driver to install, skipping ..." ) @@ -72,7 +72,7 @@ def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: } gpu: list[str] - for gpu in gpu_list: + for gpu in gpu_arr: vendor: str; gpu_info: list[str] vendor, *gpu_info = gpu From 7cb7bbb29c6ff929b20f9b5daa2515b4940dea1f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:21:13 +0800 Subject: [PATCH 119/240] return an array of appropriate gpu drvs --- src/utils/core/gpu_install.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index ec16d46..4bfb8cb 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -42,15 +42,15 @@ def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: ] -def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: +def install_gpu_drivers(log: Logger) -> list[str]: """Append the appropriate driver in the list for GPU installation. Args: log -- instance of Logger Returns: - true if the GPU was installed successfully or if there is - no driver to install and false if otherwise. + true if the GPU was installed successfully or a temporary list + for the appropriate gpu drivers """ #! THIS IS EXPERIMENTAL AND NOT TESTED DUE TO LACK OF HARDWARE @@ -58,9 +58,10 @@ def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: #! ALTHOUGH THIS CAN BE ENABLED USING A FLAG `ex` IN THE CLI #! BUT NOT IN DEFAULT OPTIONS, DO IT IN YOUR OWN DISCRETION - gpu_arr: Optional[list[list[str]]] = fetch_gpu(log) + t_gpu_drvs_arr: list[str] = [] + if not gpu_arr: log.logger( "I", "There is no GPU driver to install, skipping ..." @@ -83,9 +84,7 @@ def install_gpu_drivers(log: Logger, install_list: list[str]) -> None: ... case ["advanced micro devices", *gpu_info]: ... - case _: - continue - install_list.extend(gpu_drivers[drv_id]) + t_gpu_drvs_arr.append(gpu_drivers[drv_id]) - return None + return t_gpu_drvs_arr From c8dc21afce34aed78ffb170c1203b044497d6242 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:21:57 +0800 Subject: [PATCH 120/240] rename variable --- src/utils/core/gpu_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 4bfb8cb..39a7b9e 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -68,7 +68,7 @@ def install_gpu_drivers(log: Logger) -> list[str]: ) return None - gpu_drivers: dict[str | list[str], list[str]] = { + gpu_drv: dict[str | list[str], list[str]] = { "nvidia": ["akmod-nvidia", "xorg-x11-drv-nvidia"], } @@ -85,6 +85,6 @@ def install_gpu_drivers(log: Logger) -> list[str]: case ["advanced micro devices", *gpu_info]: ... - t_gpu_drvs_arr.append(gpu_drivers[drv_id]) + t_gpu_drvs_arr.append(gpu_drv[drv_id]) return t_gpu_drvs_arr From 27d5cb0cc08bd801fe8e272f120ef5fa12925d5d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:27:05 +0800 Subject: [PATCH 121/240] return a temporary arr again for extension of orignal arr --- src/utils/core/tp_repo_install.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index 3f6b3c6..90d0237 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -1,22 +1,14 @@ -from typing import Any - from rich.console import Console from src.utils.shared.misc.uinput import uinput -def tp_repo_install( - console: Console, - commands: list[str], - rpmfusion_repo: list[Any] - ) -> None: +def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: """Install third party repositories. Args: log -- instance of Logger console -- instance of Console - commands -- list of commands for execution - rpmfusion_repo -- list of packages to be installed """ tp_repo: dict[int, dict[str, str]] = { @@ -66,18 +58,21 @@ def tp_repo_install( } } + t_fcmd: list[list[str]] = [] + t_rfusion_install_arr: list[str] = [] + for repo in tp_repo.values(): if uinput( console, f"Install {repo.get('name')} ({repo.get('desc')})", 1 ): if repo.get("name") == "flathub": - commands.append( + t_fcmd.append( ( "flatpak remote-add --if-not-exists flathub " "https://flathub.org/repo/flathub.flatpakrepo" ) ) continue - rpmfusion_repo.append(repo.get("address")) + t_rfusion_install_arr.append(repo.get("address")) - return None + return t_fcmd, t_rfusion_install_arr From 5d00ce3a2163673504ed65329ed65dcb8448d93c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:31:52 +0800 Subject: [PATCH 122/240] use more stupid but consistent variable names --- src/utils/conf/fetch_config.py | 6 +++--- src/utils/conf/load_conf.py | 6 +++--- src/utils/core/apps_install.py | 10 +++++----- src/utils/core/apps_uninstall.py | 6 +++--- src/utils/core/gpu_install.py | 6 +++--- src/utils/core/tp_repo_install.py | 6 +++--- src/utils/shared/exec.py | 8 ++++---- src/utils/shared/fetch_env.py | 6 +++--- src/utils/shared/misc/{title_banner.py => section.py} | 10 +++++----- 9 files changed, 32 insertions(+), 32 deletions(-) rename src/utils/shared/misc/{title_banner.py => section.py} (65%) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index aaddc2a..2ee9446 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -40,8 +40,8 @@ def fetch_missing_config( ) } - trial: int - for trial in range(3): + attempt: int + for attempt in range(3): try: log.logger( "I", f"Fetching the config file ({conf_name}) from Github." @@ -60,7 +60,7 @@ def fetch_missing_config( if chunk: conf_file.write(chunk) except (ConnectionError, IOError, PermissionError) as Err: - if trial < 2: + if attempt < 2: continue log.logger( diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index d72633a..e138173 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -14,7 +14,7 @@ class Conf: def __init__(self, log: Logger) -> None: self.CONF_PATH: str = f"{Path.home()}/.config/ostree_setup" - self.CONF_LIST: list[str] = [ + self.CONF_ARR: list[str] = [ "app_for_install_flatpak", "app_for_install_rpm", "app_for_removal_flatpak", @@ -38,7 +38,7 @@ def check_missing(self) -> NoReturn | None: raise SystemExit conf_name: str - for conf_name in self.CONF_LIST: + for conf_name in self.CONF_ARR: if not exists(f"{self.CONF_PATH}/{conf_name}.json"): fetch_missing_config(self.log, conf_name, self.CONF_PATH) @@ -50,7 +50,7 @@ def load_conf(self) -> ConfigValues | NoReturn: try: parsed_conf: ConfigValues = [] - for conf_name in self.CONF_LIST: + for conf_name in self.CONF_ARR: with open( f"{self.CONF_PATH}/{conf_name}.json", "r", diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 6c86618..7daec5a 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -87,8 +87,8 @@ def _enum_apps( def app_install(self) -> tuple[list[list[str]], list[str]]: """For installation of recommended program selected by user.""" - t_finstall_cmd: list[list[str]] = [] - t_rpm_install_arr: list[str] = [] + t_fcmd: list[list[str]] = [] + t_rprog: list[str] = [] # fprog_index -> flatpak apps index # rappsindex -> rpm apps index @@ -110,7 +110,7 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: fapp_id, "--assumeyes" ] - t_finstall_cmd.append(install_cmd) + t_fcmd.append(install_cmd) #* FOR RPM PROGRAM @@ -121,6 +121,6 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: rapp_id: str = self.RPROG_ARR.get( # type: ignore self.RPROG_INDEX.get(rprog_index) # type: ignore ).get("aid") - t_rpm_install_arr.append(rapp_id) + t_rprog.append(rapp_id) - return t_finstall_cmd, t_rpm_install_arr + return t_fcmd, t_rprog diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/apps_uninstall.py index 096112a..25d19d5 100644 --- a/src/utils/core/apps_uninstall.py +++ b/src/utils/core/apps_uninstall.py @@ -9,7 +9,7 @@ def uninstall_apps(prog_arr: list[str]) -> list[list[str]]: An array of the appropriate uninstall commands """ - t_funinstall_cmds: list[list[str]] = [] + t_fcmd: list[list[str]] = [] prog: str for prog in prog_arr: @@ -21,6 +21,6 @@ def uninstall_apps(prog_arr: list[str]) -> list[list[str]]: "--system", "--assumeyes" ] - t_funinstall_cmds.append(uninstall_cmd) + t_fcmd.append(uninstall_cmd) - return t_funinstall_cmds + return t_fcmd diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 39a7b9e..723ed0e 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -60,7 +60,7 @@ def install_gpu_drivers(log: Logger) -> list[str]: gpu_arr: Optional[list[list[str]]] = fetch_gpu(log) - t_gpu_drvs_arr: list[str] = [] + t_gpu_drv: list[str] = [] if not gpu_arr: log.logger( @@ -85,6 +85,6 @@ def install_gpu_drivers(log: Logger) -> list[str]: case ["advanced micro devices", *gpu_info]: ... - t_gpu_drvs_arr.append(gpu_drv[drv_id]) + t_gpu_drv.append(gpu_drv[drv_id]) - return t_gpu_drvs_arr + return t_gpu_drv diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index 90d0237..a12432a 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -59,7 +59,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: } t_fcmd: list[list[str]] = [] - t_rfusion_install_arr: list[str] = [] + t_rfusion: list[str] = [] for repo in tp_repo.values(): if uinput( @@ -73,6 +73,6 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: ) ) continue - t_rfusion_install_arr.append(repo.get("address")) + t_rfusion.append(repo.get("address")) - return t_fcmd, t_rfusion_install_arr + return t_fcmd, t_rfusion diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index d863a72..1f6c358 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -31,12 +31,12 @@ def exec_cmd( raise SystemExit if verbose: - return_code: int = run(command).returncode + ret: int = run(command).returncode else: - return_code = run(command, stdout=DEVNULL).returncode + ret = run(command, stdout=DEVNULL).returncode - if return_code != 0: - raise CalledProcessError(return_code, command) + if ret != 0: + raise CalledProcessError(ret, command) else: log.logger("I", f"Successfully executed the command: {command}") except (OSError, CalledProcessError) as Err: diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py index 66ca5d3..e9d7275 100755 --- a/src/utils/shared/fetch_env.py +++ b/src/utils/shared/fetch_env.py @@ -19,11 +19,11 @@ def fetch_env(log: Logger, console: Console, env_var: str) -> Optional[str]: """ try: - env_value: Optional[str] = getenv(env_var.upper()) + env_val: Optional[str] = getenv(env_var.upper()) except OSError as Err: log.logger("e", f"{Err}. No value found for {env_var}.") - env_value = uinput( + env_val = uinput( console, f"Kindly input the value for {env_var}", 3 ) - return env_value + return env_val diff --git a/src/utils/shared/misc/title_banner.py b/src/utils/shared/misc/section.py similarity index 65% rename from src/utils/shared/misc/title_banner.py rename to src/utils/shared/misc/section.py index f1e16f2..83b47d3 100644 --- a/src/utils/shared/misc/title_banner.py +++ b/src/utils/shared/misc/section.py @@ -4,25 +4,25 @@ from rich.text import Text -def title_banner(banner_text: str, banner_title: str) -> None: +def section(msg: str, title: str) -> None: """For displaying of title in major operation. Args: - text -- main text to display - title -- title of the banner + txt -- main txt to display + title -- title of the section """ Console().print( Panel( Align( Text( - banner_text.upper(), + msg.upper(), justify="center" ), vertical="middle", align="center" ), - title=f"[bold]{banner_title.upper()}[/bold]" + title=f"[bold]{title.upper()}[/bold]" ) ) From a8f1e68568d1f99e318313fae60e3073ebf413f6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:32:28 +0800 Subject: [PATCH 123/240] update imports --- src/utils/core/apps_install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/core/apps_install.py b/src/utils/core/apps_install.py index 7daec5a..d494f21 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/apps_install.py @@ -3,7 +3,7 @@ from rich.console import Console from src.utils.shared.misc.uinput import uinput -from src.utils.shared.misc.title_banner import title_banner +from src.utils.shared.misc.section import section from src.utils.shared.log.logger import Logger from src.misc.alias import ProgData, ProgIndex @@ -63,7 +63,7 @@ def _enum_apps( apptype -- type of application, where flatpak or rpm """ - title_banner( + section( "installation of recommended apps", f"recommended apps ({apptype})" ) From 619ebf668c139568cf9334e58988b971036ebd39 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:37:23 +0800 Subject: [PATCH 124/240] fix mypy errors --- src/utils/conf/fetch_config.py | 2 +- src/utils/core/gpu_install.py | 4 ++-- src/utils/core/tp_repo_install.py | 25 +++++++++++++++---------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 2ee9446..bddeb16 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -46,7 +46,7 @@ def fetch_missing_config( log.logger( "I", f"Fetching the config file ({conf_name}) from Github." ) - if not (conf_link := conf_links.get(conf_name)): # type: ignore + if not (conf_link := conf_links.get(conf_name)): log.logger( "E", f"Cannot fetch the config: {conf_name}, aborting ..." ) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 723ed0e..7203d6e 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -42,7 +42,7 @@ def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: ] -def install_gpu_drivers(log: Logger) -> list[str]: +def install_gpu_drivers(log: Logger) -> list[str] | None: """Append the appropriate driver in the list for GPU installation. Args: @@ -85,6 +85,6 @@ def install_gpu_drivers(log: Logger) -> list[str]: case ["advanced micro devices", *gpu_info]: ... - t_gpu_drv.append(gpu_drv[drv_id]) + t_gpu_drv.append(gpu_drv.get(drv_id)) # type: ignore return t_gpu_drv diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index a12432a..e311be1 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -32,24 +32,24 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: ) }, 3: { - "name": "Flathub", + "name": "f_Flathub", "desc": "Unfiltered repository for flatpaks.", "address": "https://flathub.org/repo/flathub.flatpakrepo" }, 4: { - "name": "Fedora OCI", + "name": "f_Fedora OCI", "desc": "", #? what's this for?, "address": "oci+https://registry.fedoraproject.org" }, 5: { - "name": "KDE", + "name": "f_KDE", "desc": "KDE Applications.", "address": ( "https://distribute.kde.org/kdeapps.flatpakrepo" ) }, 6: { - "name": "GNOME Nightly", + "name": "f_GNOME Nightly", "desc": "For cutting edge builds from GNOME.", "address": ( "https://nightly.gnome.org/" @@ -65,14 +65,19 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: if uinput( console, f"Install {repo.get('name')} ({repo.get('desc')})", 1 ): - if repo.get("name") == "flathub": + repo_name: str = repo.get("name") # type: ignore + if repo_name.startswith("f_"): t_fcmd.append( - ( - "flatpak remote-add --if-not-exists flathub " - "https://flathub.org/repo/flathub.flatpakrepo" - ) + [ + "flatpak", + "remote-add", + "--if-not-exists", + repo.get("name"), # type: ignore + repo.get("address") # type: ignore + ] ) continue - t_rfusion.append(repo.get("address")) + + t_rfusion.append(repo.get("address")) # type: ignore return t_fcmd, t_rfusion From d903d9ebb92ae8cee208e34ba7dbe86f82a58a0e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 5 Jan 2023 05:43:39 +0800 Subject: [PATCH 125/240] rename modules --- .../core/{apps_install.py => install.py} | 24 +++++++++---------- .../core/{apps_uninstall.py => uninstall.py} | 0 2 files changed, 12 insertions(+), 12 deletions(-) rename src/utils/core/{apps_install.py => install.py} (86%) rename src/utils/core/{apps_uninstall.py => uninstall.py} (100%) diff --git a/src/utils/core/apps_install.py b/src/utils/core/install.py similarity index 86% rename from src/utils/core/apps_install.py rename to src/utils/core/install.py index d494f21..6177154 100644 --- a/src/utils/core/apps_install.py +++ b/src/utils/core/install.py @@ -9,7 +9,7 @@ -class AppInstall: +class Install: def __init__( self, log: Logger, @@ -48,24 +48,24 @@ def __init__( ) } - def _enum_apps( + def _enum_prog( self, progindex: ProgIndex, progdata: ProgData, - apptype: str + progtype: str ) -> Any: - """Enumerate the apps in the list and print out with a format. + """Enumerate the programs in the list and print out with a format. Args: progindex -- index of applications and their name progdata -- lists of the recommended applications including their application id (aid) and description - apptype -- type of application, where flatpak or rpm + progtype -- type of application, where flatpak or rpm """ section( - "installation of recommended apps", - f"recommended apps ({apptype})" + "installation of recommended programs", + f"recommended programs ({progtype})" ) index: int; appname: str @@ -84,20 +84,20 @@ def _enum_apps( 2 ) - def app_install(self) -> tuple[list[list[str]], list[str]]: + def install(self) -> tuple[list[list[str]], list[str]]: """For installation of recommended program selected by user.""" t_fcmd: list[list[str]] = [] t_rprog: list[str] = [] - # fprog_index -> flatpak apps index - # rappsindex -> rpm apps index + # fprog_index -> flatpak programs index + # rappsindex -> rpm programs index fprog_index: int; rprog_index: int #* FOR FLATPAK PROGRAMS #* appends the flatpak commands that needs to be executed in #* flatpak_cmd_list for a single execution of commands - for fprog_index in self._enum_apps( + for fprog_index in self._enum_prog( self.FPROG_INDEX, self.FPROG_ARR, "flatpak" ): fapp_id: str = self.FPROG_ARR.get( @@ -115,7 +115,7 @@ def app_install(self) -> tuple[list[list[str]], list[str]]: #* FOR RPM PROGRAM #* appends the list of name of the selected rpm applications - for rprog_index in self._enum_apps( + for rprog_index in self._enum_prog( self.RPROG_INDEX, self.RPROG_ARR, "rpm" ): rapp_id: str = self.RPROG_ARR.get( # type: ignore diff --git a/src/utils/core/apps_uninstall.py b/src/utils/core/uninstall.py similarity index 100% rename from src/utils/core/apps_uninstall.py rename to src/utils/core/uninstall.py From 636ff49a33830086f45afed5e1d0211fdc022983 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 14:51:17 +0800 Subject: [PATCH 126/240] include sections --- src/utils/core/uninstall.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/utils/core/uninstall.py b/src/utils/core/uninstall.py index 25d19d5..abea782 100644 --- a/src/utils/core/uninstall.py +++ b/src/utils/core/uninstall.py @@ -1,18 +1,28 @@ -def uninstall_apps(prog_arr: list[str]) -> list[list[str]]: +from src.utils.shared.misc.section import section + + +def uninstall_apps( + prog_arr: list[str], progtype: str + ) -> list[list[str]] | list[str]: """Uninstall preinstalled flatpak applications. Args: prog_arr -- list of apps to uninstall - flatpak_cmd_list -- all commands related to flatpak + progtype -- the type of application to remove Returns: - An array of the appropriate uninstall commands + An array of the appropriate uninstall commands or array of the + applications to uninstall """ t_fcmd: list[list[str]] = [] prog: str for prog in prog_arr: + section( + "uninstallation of unnecessary preinstalled programs", + f"listed unnecessary preinstalled programs ({progtype})" + ) uninstall_cmd: list[str] = [ "flatpak", "uninstall", From 19f5fe9d60b0548b38309989bc42e4a7b1f0280d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 14:51:39 +0800 Subject: [PATCH 127/240] turn into class to organize the methods --- src/utils/core/uninstall.py | 71 ++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/src/utils/core/uninstall.py b/src/utils/core/uninstall.py index abea782..0be51cf 100644 --- a/src/utils/core/uninstall.py +++ b/src/utils/core/uninstall.py @@ -1,36 +1,41 @@ from src.utils.shared.misc.section import section -def uninstall_apps( - prog_arr: list[str], progtype: str - ) -> list[list[str]] | list[str]: - """Uninstall preinstalled flatpak applications. - - Args: - prog_arr -- list of apps to uninstall - progtype -- the type of application to remove - - Returns: - An array of the appropriate uninstall commands or array of the - applications to uninstall - """ - - t_fcmd: list[list[str]] = [] - - prog: str - for prog in prog_arr: - section( - "uninstallation of unnecessary preinstalled programs", - f"listed unnecessary preinstalled programs ({progtype})" - ) - uninstall_cmd: list[str] = [ - "flatpak", - "uninstall", - prog, - "--delete-data", - "--system", - "--assumeyes" - ] - t_fcmd.append(uninstall_cmd) - - return t_fcmd + +class Uninstall: + def __init__(self) -> None: + pass + + def uninstall_apps( + prog_arr: list[str], progtype: str + ) -> list[list[str]] | list[str]: + """Uninstall preinstalled flatpak applications. + + Args: + prog_arr -- list of apps to uninstall + progtype -- the type of application to remove + + Returns: + An array of the appropriate uninstall commands or array of the + applications to uninstall + """ + + t_fcmd: list[list[str]] = [] + + prog: str + for prog in prog_arr: + section( + "uninstallation of unnecessary preinstalled programs", + f"listed unnecessary preinstalled programs ({progtype})" + ) + uninstall_cmd: list[str] = [ + "flatpak", + "uninstall", + prog, + "--delete-data", + "--system", + "--assumeyes" + ] + t_fcmd.append(uninstall_cmd) + + return t_fcmd From 06a36da43b314aee94991d4b73d5f73ae627aba7 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 14:55:21 +0800 Subject: [PATCH 128/240] update documentation --- src/utils/core/install.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/core/install.py b/src/utils/core/install.py index 6177154..53e45ae 100644 --- a/src/utils/core/install.py +++ b/src/utils/core/install.py @@ -10,6 +10,8 @@ class Install: + """For installation of the recommended programs.""" + def __init__( self, log: Logger, @@ -22,9 +24,9 @@ def __init__( Args: log -- instance of Logger console -- instace of console - flatpak_list -- lists of the recommended applications + fdata_arr -- lists of the recommended applications including their application id (aid) and description - rpm_list -- lists of the recommended applications + rdata_arr -- lists of the recommended applications including their application id (aid) and description verbose -- whether to display the process output or not """ @@ -35,13 +37,13 @@ def __init__( self.RPROG_ARR: ProgData = rdata_arr self.verbose: bool = verbose - self.FPROG_INDEX: ProgIndex = { + self.FPROG_INDEX: ProgIndex = { # index: program id of flatpak applications index: aid for index, aid in zip( range(len(self.FPROG_ARR.items())), self.FPROG_ARR.keys() ) } - self.RPROG_INDEX: ProgIndex = { + self.RPROG_INDEX: ProgIndex = { # index: program id of flatpak applications index: aid for index, aid in zip( range(len(self.RPROG_ARR.items())), self.RPROG_ARR.keys() From b4f92a6055f97275bedc579e9aafcd0f34a97270 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 14:58:38 +0800 Subject: [PATCH 129/240] remove unused parameters and variables --- src/utils/core/install.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/utils/core/install.py b/src/utils/core/install.py index 53e45ae..a64094f 100644 --- a/src/utils/core/install.py +++ b/src/utils/core/install.py @@ -1,10 +1,7 @@ from typing import Any -from rich.console import Console - from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.section import section -from src.utils.shared.log.logger import Logger from src.misc.alias import ProgData, ProgIndex @@ -13,29 +10,19 @@ class Install: """For installation of the recommended programs.""" def __init__( - self, - log: Logger, - console: Console, - fdata_arr: ProgData, - rdata_arr: ProgData, - verbose: bool = False + self, fdata_arr: ProgData, rdata_arr: ProgData ) -> None: """ Args: log -- instance of Logger - console -- instace of console fdata_arr -- lists of the recommended applications including their application id (aid) and description rdata_arr -- lists of the recommended applications including their application id (aid) and description - verbose -- whether to display the process output or not """ - self.log: Logger = log - self.console: Console = console self.FPROG_ARR: ProgData = fdata_arr self.RPROG_ARR: ProgData = rdata_arr - self.verbose: bool = verbose self.FPROG_INDEX: ProgIndex = { # index: program id of flatpak applications index: aid for index, aid in zip( From e8880816d7c5597e9e1713a5025e25d49ebd52c9 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:05:40 +0800 Subject: [PATCH 130/240] rename variables to avoid confusion used: prefix fp_ -> flatpak prefix rpm_ -> rpm --- src/utils/core/install.py | 72 +++++++++++++++---------------- src/utils/core/tp_repo_install.py | 6 +-- src/utils/core/uninstall.py | 6 +-- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/utils/core/install.py b/src/utils/core/install.py index a64094f..bd4c6cf 100644 --- a/src/utils/core/install.py +++ b/src/utils/core/install.py @@ -10,30 +10,30 @@ class Install: """For installation of the recommended programs.""" def __init__( - self, fdata_arr: ProgData, rdata_arr: ProgData + self, fp_data_arr: ProgData, rpm_data_arr: ProgData ) -> None: """ Args: log -- instance of Logger - fdata_arr -- lists of the recommended applications + fp_data_arr -- lists of the recommended applications including their application id (aid) and description - rdata_arr -- lists of the recommended applications + rpm_data_arr -- lists of the recommended applications including their application id (aid) and description """ - self.FPROG_ARR: ProgData = fdata_arr - self.RPROG_ARR: ProgData = rdata_arr + self.fp_PROGARR: ProgData = fp_data_arr + self.rpm_PROGARR: ProgData = rpm_data_arr - self.FPROG_INDEX: ProgIndex = { # index: program id of flatpak applications - index: aid for index, aid in zip( - range(len(self.FPROG_ARR.items())), - self.FPROG_ARR.keys() + self.fp_PROGIND: ProgIndex = { # ind: program id of flatpak applications + ind: aid for ind, aid in zip( + range(len(self.fp_PROGARR.items())), + self.fp_PROGARR.keys() ) } - self.RPROG_INDEX: ProgIndex = { # index: program id of flatpak applications - index: aid for index, aid in zip( - range(len(self.RPROG_ARR.items())), - self.RPROG_ARR.keys() + self.rpm_PROGIND: ProgIndex = { # ind: program id of flatpak applications + ind: aid for ind, aid in zip( + range(len(self.rpm_PROGARR.items())), + self.rpm_PROGARR.keys() ) } @@ -46,7 +46,7 @@ def _enum_prog( """Enumerate the programs in the list and print out with a format. Args: - progindex -- index of applications and their name + progindex -- ind of applications and their name progdata -- lists of the recommended applications including their application id (aid) and description progtype -- type of application, where flatpak or rpm @@ -57,13 +57,13 @@ def _enum_prog( f"recommended programs ({progtype})" ) - index: int; appname: str - for index, appname in progindex.items(): + ind: int; progname: str + for ind, progname in progindex.items(): self.console.print( ( - f"[bold cyan]{index:4}[/bold cyan] " - f"[bold]{appname}[/bold] -- " - f"{progdata.get(appname).get('sdesc')}" # type: ignore + f"[bold cyan]{ind:4}[/bold cyan] " + f"[bold]{progname}[/bold] -- " + f"{progdata.get(progname).get('sdesc')}" # type: ignore ) ) @@ -76,40 +76,40 @@ def _enum_prog( def install(self) -> tuple[list[list[str]], list[str]]: """For installation of recommended program selected by user.""" - t_fcmd: list[list[str]] = [] - t_rprog: list[str] = [] + t_fp_cmd: list[list[str]] = [] + t_rpm_prog: list[str] = [] - # fprog_index -> flatpak programs index - # rappsindex -> rpm programs index - fprog_index: int; rprog_index: int + # fp_ind -> flatpak programs ind + # rappsindex -> rpm programs ind + fp_ind: int; rpm_ind: int #* FOR FLATPAK PROGRAMS #* appends the flatpak commands that needs to be executed in #* flatpak_cmd_list for a single execution of commands - for fprog_index in self._enum_prog( - self.FPROG_INDEX, self.FPROG_ARR, "flatpak" + for fp_ind in self._enum_prog( + self.fp_PROGIND, self.fp_PROGARR, "flatpak" ): - fapp_id: str = self.FPROG_ARR.get( - self.FPROG_INDEX.get(fprog_index) # type: ignore + fp_aid: str = self.fp_PROGARR.get( + self.fp_PROGIND.get(fp_ind) # type: ignore ).get("aid") install_cmd: list[str] = [ "flatpak", "install", "flathub", - fapp_id, + fp_aid, "--assumeyes" ] - t_fcmd.append(install_cmd) + t_fp_cmd.append(install_cmd) #* FOR RPM PROGRAM #* appends the list of name of the selected rpm applications - for rprog_index in self._enum_prog( - self.RPROG_INDEX, self.RPROG_ARR, "rpm" + for rpm_ind in self._enum_prog( + self.rpm_PROGIND, self.rpm_PROGARR, "rpm" ): - rapp_id: str = self.RPROG_ARR.get( # type: ignore - self.RPROG_INDEX.get(rprog_index) # type: ignore + r_aid: str = self.rpm_PROGARR.get( # type: ignore + self.rpm_PROGIND.get(rpm_ind) # type: ignore ).get("aid") - t_rprog.append(rapp_id) + t_rpm_prog.append(r_aid) - return t_fcmd, t_rprog + return t_fp_cmd, t_rpm_prog diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index e311be1..051cd06 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -58,7 +58,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: } } - t_fcmd: list[list[str]] = [] + t_fp_cmd: list[list[str]] = [] t_rfusion: list[str] = [] for repo in tp_repo.values(): @@ -67,7 +67,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: ): repo_name: str = repo.get("name") # type: ignore if repo_name.startswith("f_"): - t_fcmd.append( + t_fp_cmd.append( [ "flatpak", "remote-add", @@ -80,4 +80,4 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: t_rfusion.append(repo.get("address")) # type: ignore - return t_fcmd, t_rfusion + return t_fp_cmd, t_rfusion diff --git a/src/utils/core/uninstall.py b/src/utils/core/uninstall.py index 0be51cf..b9e978d 100644 --- a/src/utils/core/uninstall.py +++ b/src/utils/core/uninstall.py @@ -20,7 +20,7 @@ def uninstall_apps( applications to uninstall """ - t_fcmd: list[list[str]] = [] + t_fp_cmd: list[list[str]] = [] prog: str for prog in prog_arr: @@ -36,6 +36,6 @@ def uninstall_apps( "--system", "--assumeyes" ] - t_fcmd.append(uninstall_cmd) + t_fp_cmd.append(uninstall_cmd) - return t_fcmd + return t_fp_cmd From 3653345c7b4b051e3ac6ef0faa2d502bd726a701 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:12:58 +0800 Subject: [PATCH 131/240] include aid and sdesc value for the keys this will allow users to be more informed of decisions that they will make --- config/app_for_removal_rpm.json | 69 ++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/config/app_for_removal_rpm.json b/config/app_for_removal_rpm.json index 4e11b31..5e9f422 100644 --- a/config/app_for_removal_rpm.json +++ b/config/app_for_removal_rpm.json @@ -1,15 +1,54 @@ -[ - "libavcodec-free", - "open-vm-tools-desktop", - "open-vm-tools", - "qemu-guest-agent", - "spice-vdagent", - "spice-webdavd", - "virtualbox-guest-additions", - "gnome-shell-extension-apps-menu", - "gnome-classic-session", - "gnome-shell-extension-window-list", - "gnome-shell-extension-background-logo", - "gnome-shell-extension-launch-new-instance", - "gnome-shell-extension-places-menu" -] +{ + "libavcodec-free": { + "aid": "", + "sdesc": "" + }, + "open-vm-tools-desktop": { + "aid": "", + "sdesc": "" + }, + "open-vm-tools": { + "aid": "", + "sdesc": "" + }, + "qemu-guest-agent": { + "aid": "", + "sdesc": "" + }, + "spice-vdagent": { + "aid": "", + "sdesc": "" + }, + "spice-webdavd": { + "aid": "", + "sdesc": "" + }, + "virtualbox-guest-additions": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-apps-menu": { + "aid": "", + "sdesc": "" + }, + "gnome-classic-session": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-window-list": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-background-logo": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-launch-new-instance": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-places-menu": { + "aid": "", + "sdesc": "" + } +} From 968d6938d9514d89b97cbc742c3b07941f225367 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:16:04 +0800 Subject: [PATCH 132/240] use the same format to include more information about the recommended programs --- config/app_for_removal_flatpak.json | 76 +++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/config/app_for_removal_flatpak.json b/config/app_for_removal_flatpak.json index ff10521..3d019f3 100644 --- a/config/app_for_removal_flatpak.json +++ b/config/app_for_removal_flatpak.json @@ -1,17 +1,63 @@ { - "Calculator": "org.gnome.Calculator", - "Calendar": "org.gnome.Calendar", - "Characters": "org.gnome.Characters", - "Connections": "org.gnome.Connections", - "Contacts": "org.gnome.Contacts", - "Evince": "org.gnome.Evince", - "Extensions": "org.gnome.Extensions", - "Logs": "org.gnome.Logs", - "Maps": "org.gnome.Maps", - "Text Editor": "org.gnome.TextEditor", - "Weather": "org.gnome.Weather", - "Disk Usage Analyzer": "org.gnome.baobab", - "Clocks": "org.gnome.Clocks", - "Image Viewer": "org.gnome.eog", - "Fonts Viewer": "org.gnome.fonts-viewer" + "org.gnome.Calculator": { + "aid": "Calculator", + "sdesc": "" + }, + "org.gnome.Calendar": { + "aid": "Calendar", + "sdesc": "" + }, + "org.gnome.Characters": { + "aid": "Characters", + "sdesc": "" + }, + "org.gnome.Connections": { + "aid": "Connections", + "sdesc": "" + }, + "org.gnome.Contacts": { + "aid": "Contacts", + "sdesc": "" + }, + "org.gnome.Evince": { + "aid": "Evince", + "sdesc": "" + }, + "org.gnome.Extensions": { + "aid": "Extensions", + "sdesc": "" + }, + "org.gnome.Logs": { + "aid": "Logs", + "sdesc": "" + }, + "org.gnome.Maps": { + "aid": "Maps", + "sdesc": "" + }, + "org.gnome.TextEditor": { + "aid": "Text Editor", + "sdesc": "" + }, + "org.gnome.Weather": { + "aid": "Weather", + "sdesc": "" + }, + "org.gnome.baobab": { + "aid": "Disk Usage Analyzer", + "sdesc": "" + }, + "org.gnome.Clocks": { + "aid": "Clocks", + "sdesc": "" + }, + "org.gnome.eog": { + "aid": "Image Viewer", + "sdesc": "" + }, + "org.gnome.fonts-viewer": { + "aid": "Fonts Viewer", + "sdesc": "" + } } + From 8dd587113dd5d8574050375d749d1c95c762c903 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:17:39 +0800 Subject: [PATCH 133/240] merge the flatpak and rpm program for install list --- config/app_for_install.json | 154 ++++++++++++++++++++++++++++ config/app_for_install_flatpak.json | 82 --------------- config/app_for_install_rpm.json | 71 ------------- 3 files changed, 154 insertions(+), 153 deletions(-) create mode 100644 config/app_for_install.json delete mode 100644 config/app_for_install_flatpak.json delete mode 100644 config/app_for_install_rpm.json diff --git a/config/app_for_install.json b/config/app_for_install.json new file mode 100644 index 0000000..4977318 --- /dev/null +++ b/config/app_for_install.json @@ -0,0 +1,154 @@ +[ + { + "Mailspring": { + "aid": "com.getmailspring.Mailspring", + "sdesc": "A simple email client." + }, + "LibreOffice": { + "aid": "org.libreoffice.LibreOffice", + "sdesc": "Office suite." + }, + "VLC": { + "aid": "org.videolan.VLC", + "sdesc": "Video player." + }, + "Okular": { + "aid": "org.kde.okular", + "sdesc": "A document viewer." + }, + "GIMP": { + "aid": "org.gimp.GIMP", + "sdesc": "Photo editing application." + }, + "ClamTk": { + "aid": "com.gitlab.davem.ClamTk", + "sdesc": "Front end for ClamAV." + }, + "FlatSeal": { + "aid": "com.github.tchx84.Flatseal", + "sdesc": "GUI for managing flatpak applications permission" + }, + "KeepassXC": { + "aid": "org.keepassxc.KeePassXC", + "sdesc": "Secure Password manager." + }, + "Cryptomator": { + "aid": "org.cryptomator.Cryptomator", + "sdesc": "Secure and easy encryption, especially for Cloud storages." + }, + "Easy-Effects": { + "aid": "com.github.wwmm.easyeffects", + "sdesc": "Modify your PulseAudio sound" + }, + "Sync-Thingy": { + "aid": "com.github.zocker_160.SyncThingy", + "sdesc": "Sync folders securely between devices, no server." + }, + "XNView MP": { + "aid": "com.xnview.XnViewMP", + "sdesc": "Image Viewer and editor with many functions" + }, + "Freetube": { + "aid": "io.freetubeapp.FreeTube", + "sdesc": "Watch YouTube privately with local subscriptions and playlists." + }, + "Inkscape": { + "aid": "org.inkscape.Inkscape", + "sdesc": "A Vector graphics program" + }, + "GNOME Boxen": { + "aid": "org.gnome.Boxes", + "sdesc": "Manage fast Virtual machines with a simple interface." + }, + "Filelight": { + "aid": "org.kde.filelight ", + "sdesc": "View what files consume how much space in a pie chart." + }, + "Kdenlive": { + "aid": "org.kde.kdenlive", + "sdesc": "Video cut program" + }, + "Onion Share": { + "aid": "org.onionshare.OnionShare", + "sdesc": "Share files, chat and create websites over Tor" + }, + "qBittorrent": { + "aid": "org.qbittorrent.qBittorrent", + "sdesc": "Share files decentral with a big community." + }, + "Metadata-cleaner": { + "aid": "fr.romainvigier.MetadataCleaner", + "sdesc": "Easily remove all identifying information on Images using exiftool." + } + }, + { + "exiftool": { + "aid": "", + "sdesc": "" + }, + "perl-Image-ExifTool": { + "aid": "", + "sdesc": "" + }, + "clamtk*": { + "aid": "", + "sdesc": "" + }, + "fail2ban": { + "aid": "", + "sdesc": "" + }, + "tlp": { + "aid": "", + "sdesc": "" + }, + "make": { + "aid": "", + "sdesc": "" + }, + "gcc-c++": { + "aid": "", + "sdesc": "" + }, + "qemu-kvm": { + "aid": "", + "sdesc": "" + }, + "qemu-img": { + "aid": "", + "sdesc": "" + }, + "qemu-user-static": { + "aid": "", + "sdesc": "" + }, + "ffmpegthumbs": { + "aid": "", + "sdesc": "" + }, + "kffmpegthumbnailer": { + "aid": "", + "sdesc": "" + }, + "unrar": { + "aid": "", + "sdesc": "" + }, + "stacer": { + "aid": "", + "sdesc": "" + }, + "python-pip": { + "aid": "", + "sdesc": "" + }, + "android-tools": { + "aid": "", + "sdesc": "" + }, + "btfs": { + "aid": "", + "sdesc": "" + } + } +] diff --git a/config/app_for_install_flatpak.json b/config/app_for_install_flatpak.json deleted file mode 100644 index f2db2f1..0000000 --- a/config/app_for_install_flatpak.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "Mailspring": { - "aid": "com.getmailspring.Mailspring", - "sdesc": "A simple email client." - }, - "LibreOffice": { - "aid": "org.libreoffice.LibreOffice", - "sdesc": "Office suite." - }, - "VLC": { - "aid": "org.videolan.VLC", - "sdesc": "Video player." - }, - "Okular": { - "aid": "org.kde.okular", - "sdesc": "A document viewer." - }, - "GIMP": { - "aid": "org.gimp.GIMP", - "sdesc": "Photo editing application." - }, - "ClamTk": { - "aid": "com.gitlab.davem.ClamTk", - "sdesc": "Front end for ClamAV." - }, - "FlatSeal": { - "aid": "com.github.tchx84.Flatseal", - "sdesc": "GUI for managing flatpak applications permission" - }, - "KeepassXC": { - "aid": "org.keepassxc.KeePassXC", - "sdesc": "Secure Password manager." - }, - "Cryptomator": { - "aid": "org.cryptomator.Cryptomator", - "sdesc": "Secure and easy encryption, especially for Cloud storages." - }, - "Easy-Effects": { - "aid": "com.github.wwmm.easyeffects", - "sdesc": "Modify your PulseAudio sound" - }, - "Sync-Thingy": { - "aid": "com.github.zocker_160.SyncThingy", - "sdesc": "Sync folders securely between devices, no server." - }, - "XNView MP": { - "aid": "com.xnview.XnViewMP", - "sdesc": "Image Viewer and editor with many functions" - }, - "Freetube": { - "aid": "io.freetubeapp.FreeTube", - "sdesc": "Watch YouTube privately with local subscriptions and playlists." - }, - "Inkscape": { - "aid": "org.inkscape.Inkscape", - "sdesc": "A Vector graphics program" - }, - "GNOME Boxen": { - "aid": "org.gnome.Boxes", - "sdesc": "Manage fast Virtual machines with a simple interface." - }, - "Filelight": { - "aid": "org.kde.filelight ", - "sdesc": "View what files consume how much space in a pie chart." - }, - "Kdenlive": { - "aid": "org.kde.kdenlive", - "sdesc": "Video cut program" - }, - "Onion Share": { - "aid": "org.onionshare.OnionShare", - "sdesc": "Share files, chat and create websites over Tor" - }, - "qBittorrent": { - "aid": "org.qbittorrent.qBittorrent", - "sdesc": "Share files decentral with a big community." - }, - "Metadata-cleaner": { - "aid": "fr.romainvigier.MetadataCleaner", - "sdesc": "Easily remove all identifying information on Images using exiftool." - } -} diff --git a/config/app_for_install_rpm.json b/config/app_for_install_rpm.json deleted file mode 100644 index 097bcc5..0000000 --- a/config/app_for_install_rpm.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "exiftool": { - "aid": "", - "sdesc": "" - }, - "perl-Image-ExifTool": { - "aid": "", - "sdesc": "" - }, - "clamtk*": { - "aid": "", - "sdesc": "" - }, - "fail2ban": { - "aid": "", - "sdesc": "" - }, - "tlp": { - "aid": "", - "sdesc": "" - }, - "make": { - "aid": "", - "sdesc": "" - }, - "gcc-c++": { - "aid": "", - "sdesc": "" - }, - "qemu-kvm": { - "aid": "", - "sdesc": "" - }, - "qemu-img": { - "aid": "", - "sdesc": "" - }, - "qemu-user-static": { - "aid": "", - "sdesc": "" - }, - "ffmpegthumbs": { - "aid": "", - "sdesc": "" - }, - "kffmpegthumbnailer": { - "aid": "", - "sdesc": "" - }, - "unrar": { - "aid": "", - "sdesc": "" - }, - "stacer": { - "aid": "", - "sdesc": "" - }, - "python-pip": { - "aid": "", - "sdesc": "" - }, - "android-tools": { - "aid": "", - "sdesc": "" - }, - "btfs": { - "aid": "", - "sdesc": "" - } -} - From 4bda9289ba9a8fe39807f3cbf3bfd0ae8b6c3f20 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:19:22 +0800 Subject: [PATCH 134/240] merge the json of flatpak and rpm uinstall list --- config/app_for_removal.json | 118 ++++++++++++++++++++++++++++ config/app_for_removal_flatpak.json | 63 --------------- config/app_for_removal_rpm.json | 54 ------------- 3 files changed, 118 insertions(+), 117 deletions(-) create mode 100644 config/app_for_removal.json delete mode 100644 config/app_for_removal_flatpak.json delete mode 100644 config/app_for_removal_rpm.json diff --git a/config/app_for_removal.json b/config/app_for_removal.json new file mode 100644 index 0000000..a9adea6 --- /dev/null +++ b/config/app_for_removal.json @@ -0,0 +1,118 @@ +[ + { + "org.gnome.Calculator": { + "aid": "Calculator", + "sdesc": "" + }, + "org.gnome.Calendar": { + "aid": "Calendar", + "sdesc": "" + }, + "org.gnome.Characters": { + "aid": "Characters", + "sdesc": "" + }, + "org.gnome.Connections": { + "aid": "Connections", + "sdesc": "" + }, + "org.gnome.Contacts": { + "aid": "Contacts", + "sdesc": "" + }, + "org.gnome.Evince": { + "aid": "Evince", + "sdesc": "" + }, + "org.gnome.Extensions": { + "aid": "Extensions", + "sdesc": "" + }, + "org.gnome.Logs": { + "aid": "Logs", + "sdesc": "" + }, + "org.gnome.Maps": { + "aid": "Maps", + "sdesc": "" + }, + "org.gnome.TextEditor": { + "aid": "Text Editor", + "sdesc": "" + }, + "org.gnome.Weather": { + "aid": "Weather", + "sdesc": "" + }, + "org.gnome.baobab": { + "aid": "Disk Usage Analyzer", + "sdesc": "" + }, + "org.gnome.Clocks": { + "aid": "Clocks", + "sdesc": "" + }, + "org.gnome.eog": { + "aid": "Image Viewer", + "sdesc": "" + }, + "org.gnome.fonts-viewer": { + "aid": "Fonts Viewer", + "sdesc": "" + } + }, + { + "libavcodec-free": { + "aid": "", + "sdesc": "" + }, + "open-vm-tools-desktop": { + "aid": "", + "sdesc": "" + }, + "open-vm-tools": { + "aid": "", + "sdesc": "" + }, + "qemu-guest-agent": { + "aid": "", + "sdesc": "" + }, + "spice-vdagent": { + "aid": "", + "sdesc": "" + }, + "spice-webdavd": { + "aid": "", + "sdesc": "" + }, + "virtualbox-guest-additions": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-apps-menu": { + "aid": "", + "sdesc": "" + }, + "gnome-classic-session": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-window-list": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-background-logo": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-launch-new-instance": { + "aid": "", + "sdesc": "" + }, + "gnome-shell-extension-places-menu": { + "aid": "", + "sdesc": "" + } + } +] diff --git a/config/app_for_removal_flatpak.json b/config/app_for_removal_flatpak.json deleted file mode 100644 index 3d019f3..0000000 --- a/config/app_for_removal_flatpak.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "org.gnome.Calculator": { - "aid": "Calculator", - "sdesc": "" - }, - "org.gnome.Calendar": { - "aid": "Calendar", - "sdesc": "" - }, - "org.gnome.Characters": { - "aid": "Characters", - "sdesc": "" - }, - "org.gnome.Connections": { - "aid": "Connections", - "sdesc": "" - }, - "org.gnome.Contacts": { - "aid": "Contacts", - "sdesc": "" - }, - "org.gnome.Evince": { - "aid": "Evince", - "sdesc": "" - }, - "org.gnome.Extensions": { - "aid": "Extensions", - "sdesc": "" - }, - "org.gnome.Logs": { - "aid": "Logs", - "sdesc": "" - }, - "org.gnome.Maps": { - "aid": "Maps", - "sdesc": "" - }, - "org.gnome.TextEditor": { - "aid": "Text Editor", - "sdesc": "" - }, - "org.gnome.Weather": { - "aid": "Weather", - "sdesc": "" - }, - "org.gnome.baobab": { - "aid": "Disk Usage Analyzer", - "sdesc": "" - }, - "org.gnome.Clocks": { - "aid": "Clocks", - "sdesc": "" - }, - "org.gnome.eog": { - "aid": "Image Viewer", - "sdesc": "" - }, - "org.gnome.fonts-viewer": { - "aid": "Fonts Viewer", - "sdesc": "" - } -} - diff --git a/config/app_for_removal_rpm.json b/config/app_for_removal_rpm.json deleted file mode 100644 index 5e9f422..0000000 --- a/config/app_for_removal_rpm.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "libavcodec-free": { - "aid": "", - "sdesc": "" - }, - "open-vm-tools-desktop": { - "aid": "", - "sdesc": "" - }, - "open-vm-tools": { - "aid": "", - "sdesc": "" - }, - "qemu-guest-agent": { - "aid": "", - "sdesc": "" - }, - "spice-vdagent": { - "aid": "", - "sdesc": "" - }, - "spice-webdavd": { - "aid": "", - "sdesc": "" - }, - "virtualbox-guest-additions": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-apps-menu": { - "aid": "", - "sdesc": "" - }, - "gnome-classic-session": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-window-list": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-background-logo": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-launch-new-instance": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-places-menu": { - "aid": "", - "sdesc": "" - } -} From f8a43092dec2e778e9b2b9d8dca8177411b5f2f4 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:21:04 +0800 Subject: [PATCH 135/240] remove deprecated config files in the arr --- src/utils/conf/fetch_config.py | 12 ++---------- src/utils/conf/load_conf.py | 6 ++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index bddeb16..b5e8eaf 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -17,23 +17,15 @@ def fetch_missing_config( """ conf_links: dict[str, str] = { - "app_for_install_flatpak": ( + "app_for_install": ( "https://raw.githubusercontent.com/iaacornus/Fedora" "-OSTree-Setup/devel/config/app_for_install_flatpak.json" ), - "app_for_install_rpm": ( - "https://raw.githubusercontent.com/iaacornus/Fedora" - "-OSTree-Setup/devel/config/app_for_install_rpm.json" - ), - "app_for_removal_flatpak": ( + "app_for_removal": ( "https://raw.githubusercontent.com/iaacornus/Fedora" "-OSTree-Setup/devel/config/app_for_removal_flatpak.json" ), - "app_for_removal_rpm": ( - "https://raw.githubusercontent.com/iaacornus/Fedora" - "-OSTree-Setup/devel/config/app_for_removal_rpm.json" - ), "ostree_setup": ( "https://raw.githubusercontent.com/iaacornus/Fedora-" "OSTree-Setup/devel/config/ostree_setup.json" diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index e138173..039ed6c 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -15,10 +15,8 @@ class Conf: def __init__(self, log: Logger) -> None: self.CONF_PATH: str = f"{Path.home()}/.config/ostree_setup" self.CONF_ARR: list[str] = [ - "app_for_install_flatpak", - "app_for_install_rpm", - "app_for_removal_flatpak", - "app_for_removal_rpm", + "app_for_install", + "app_for_removal", "ostree_setup" ] From 878ac106891f57d0c36a04a683dc5d089c28425d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:21:27 +0800 Subject: [PATCH 136/240] initial commit on revision of uninstall class --- src/utils/core/uninstall.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/core/uninstall.py b/src/utils/core/uninstall.py index b9e978d..b1842a0 100644 --- a/src/utils/core/uninstall.py +++ b/src/utils/core/uninstall.py @@ -1,9 +1,13 @@ from src.utils.shared.misc.section import section - +from src.misc.alias import ProgData class Uninstall: - def __init__(self) -> None: + """For uninstallation of programs.""" + + def __init__( + fp_data_arr: ProgData, rpm_data_arr: ProgData + ) -> None: pass def uninstall_apps( From 2da4a8b1168a7005d75c8c379523568f65ba5eed Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:22:44 +0800 Subject: [PATCH 137/240] update address of configs for fetch --- src/utils/conf/fetch_config.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index b5e8eaf..ec01291 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -18,13 +18,12 @@ def fetch_missing_config( conf_links: dict[str, str] = { "app_for_install": ( - "https://raw.githubusercontent.com/iaacornus/Fedora" - "-OSTree-Setup/devel/config/app_for_install_flatpak.json" - + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_install.json" ), "app_for_removal": ( - "https://raw.githubusercontent.com/iaacornus/Fedora" - "-OSTree-Setup/devel/config/app_for_removal_flatpak.json" + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_removal.json" ), "ostree_setup": ( "https://raw.githubusercontent.com/iaacornus/Fedora-" From b72f332b08dd019b1997db3f04536e3333d77676 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:24:22 +0800 Subject: [PATCH 138/240] update configvalues alias to the new config --- src/misc/alias.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/misc/alias.py b/src/misc/alias.py index ef73b7d..b170044 100644 --- a/src/misc/alias.py +++ b/src/misc/alias.py @@ -1,3 +1,5 @@ -ProgData = dict[str, dict[str, str]] -ProgIndex = dict[int, str] -ConfigValues = list[list[str] | dict[str, str | dict[str, str]]] +ProgData = dict[str, dict[str, str]] +ProgIndex = dict[int, str] +ConfigValues = list[ + list[dict[str, str | dict[str, str]]] | dict[str, str] + ] From 191b18fd292e5182f068a09e35352198bea3ae26 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Fri, 6 Jan 2023 15:26:46 +0800 Subject: [PATCH 139/240] put back console --- src/utils/core/install.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/core/install.py b/src/utils/core/install.py index bd4c6cf..b8d138c 100644 --- a/src/utils/core/install.py +++ b/src/utils/core/install.py @@ -1,5 +1,7 @@ from typing import Any +from rich.console import Console + from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.section import section from src.misc.alias import ProgData, ProgIndex @@ -10,17 +12,22 @@ class Install: """For installation of the recommended programs.""" def __init__( - self, fp_data_arr: ProgData, rpm_data_arr: ProgData + self, + console: Console, + fp_data_arr: ProgData, + rpm_data_arr: ProgData ) -> None: """ Args: log -- instance of Logger + console -- instance of Console fp_data_arr -- lists of the recommended applications including their application id (aid) and description rpm_data_arr -- lists of the recommended applications including their application id (aid) and description """ + self.console: Console = console self.fp_PROGARR: ProgData = fp_data_arr self.rpm_PROGARR: ProgData = rpm_data_arr From 84389c41237c47bdcfdd444b1b2fe1b09617f433 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 8 Jan 2023 23:41:09 +0800 Subject: [PATCH 140/240] combine install.py & uninstall.py --- src/utils/core/{install.py => add_remove.py} | 45 +++++++++++++------- src/utils/core/uninstall.py | 45 -------------------- 2 files changed, 29 insertions(+), 61 deletions(-) rename src/utils/core/{install.py => add_remove.py} (77%) delete mode 100644 src/utils/core/uninstall.py diff --git a/src/utils/core/install.py b/src/utils/core/add_remove.py similarity index 77% rename from src/utils/core/install.py rename to src/utils/core/add_remove.py index b8d138c..20ca87d 100644 --- a/src/utils/core/install.py +++ b/src/utils/core/add_remove.py @@ -7,30 +7,33 @@ from src.misc.alias import ProgData, ProgIndex - -class Install: +class ProgramSetup: """For installation of the recommended programs.""" def __init__( self, console: Console, fp_data_arr: ProgData, - rpm_data_arr: ProgData + rpm_data_arr: ProgData, + action: str ) -> None: """ Args: - log -- instance of Logger console -- instance of Console fp_data_arr -- lists of the recommended applications including their application id (aid) and description rpm_data_arr -- lists of the recommended applications including their application id (aid) and description + action -- whether uninstall or install """ self.console: Console = console + self.fp_PROGARR: ProgData = fp_data_arr self.rpm_PROGARR: ProgData = rpm_data_arr + self.action: str = action + self.fp_PROGIND: ProgIndex = { # ind: program id of flatpak applications ind: aid for ind, aid in zip( range(len(self.fp_PROGARR.items())), @@ -60,8 +63,8 @@ def _enum_prog( """ section( - "installation of recommended programs", - f"recommended programs ({progtype})" + f"{self.action}ion of recommended programs" + f"recommended programs ({progtype})", ) ind: int; progname: str @@ -80,8 +83,8 @@ def _enum_prog( 2 ) - def install(self) -> tuple[list[list[str]], list[str]]: - """For installation of recommended program selected by user.""" + def setup(self) -> tuple[list[list[str]], list[str]]: + """For add/remove of recommended program selected by user.""" t_fp_cmd: list[list[str]] = [] t_rpm_prog: list[str] = [] @@ -99,15 +102,25 @@ def install(self) -> tuple[list[list[str]], list[str]]: fp_aid: str = self.fp_PROGARR.get( self.fp_PROGIND.get(fp_ind) # type: ignore ).get("aid") - install_cmd: list[str] = [ - "flatpak", - "install", - "flathub", - fp_aid, - "--assumeyes" - ] - t_fp_cmd.append(install_cmd) + if self.action.lower() == "install": + fp_cmd: list[str] = [ + "flatpak", + "install", + "flathub", + fp_aid, + "--assumeyes" + ] + else: + fp_cmd = [ + "flatpak", + "uninstall", + fp_aid, + "--system", + "--delete-data", + "--assumeyes" + ] + t_fp_cmd.append(fp_cmd) #* FOR RPM PROGRAM #* appends the list of name of the selected rpm applications diff --git a/src/utils/core/uninstall.py b/src/utils/core/uninstall.py deleted file mode 100644 index b1842a0..0000000 --- a/src/utils/core/uninstall.py +++ /dev/null @@ -1,45 +0,0 @@ -from src.utils.shared.misc.section import section -from src.misc.alias import ProgData - - -class Uninstall: - """For uninstallation of programs.""" - - def __init__( - fp_data_arr: ProgData, rpm_data_arr: ProgData - ) -> None: - pass - - def uninstall_apps( - prog_arr: list[str], progtype: str - ) -> list[list[str]] | list[str]: - """Uninstall preinstalled flatpak applications. - - Args: - prog_arr -- list of apps to uninstall - progtype -- the type of application to remove - - Returns: - An array of the appropriate uninstall commands or array of the - applications to uninstall - """ - - t_fp_cmd: list[list[str]] = [] - - prog: str - for prog in prog_arr: - section( - "uninstallation of unnecessary preinstalled programs", - f"listed unnecessary preinstalled programs ({progtype})" - ) - uninstall_cmd: list[str] = [ - "flatpak", - "uninstall", - prog, - "--delete-data", - "--system", - "--assumeyes" - ] - t_fp_cmd.append(uninstall_cmd) - - return t_fp_cmd From 29699b176c69566676447cb4f08a4bd73750ef80 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 8 Jan 2023 23:42:49 +0800 Subject: [PATCH 141/240] include fp_ and rpm_ prefixes to separate flatpaks from rpms --- src/utils/core/tp_repo_install.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index 051cd06..aa2d546 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -14,7 +14,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: tp_repo: dict[int, dict[str, str]] = { # id and name of the repo and the address 1: { - "name": "RPMFusion (Free)", + "name": "rpm_RPMFusion (Free)", "desc": "Fedora repository for open source softwares.", "address": ( r"https://mirrors.rpmfusion.org/" @@ -23,7 +23,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: ) }, 2: { - "name": "RPMFusion (Non-free)", + "name": "rpm_RPMFusion (Non-free)", "desc": "Fedora repository for propietary software.", "address": ( r"https://mirrors.rpmfusion.org/" @@ -32,24 +32,24 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: ) }, 3: { - "name": "f_Flathub", + "name": "fp_Flathub", "desc": "Unfiltered repository for flatpaks.", "address": "https://flathub.org/repo/flathub.flatpakrepo" }, 4: { - "name": "f_Fedora OCI", + "name": "fp_Fedora OCI", "desc": "", #? what's this for?, "address": "oci+https://registry.fedoraproject.org" }, 5: { - "name": "f_KDE", + "name": "fp_KDE", "desc": "KDE Applications.", "address": ( "https://distribute.kde.org/kdeapps.flatpakrepo" ) }, 6: { - "name": "f_GNOME Nightly", + "name": "fp_GNOME Nightly", "desc": "For cutting edge builds from GNOME.", "address": ( "https://nightly.gnome.org/" @@ -63,10 +63,12 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: for repo in tp_repo.values(): if uinput( - console, f"Install {repo.get('name')} ({repo.get('desc')})", 1 + console, + f"Install {repo.get('name')} ({repo.get('desc')})", + 1 ): repo_name: str = repo.get("name") # type: ignore - if repo_name.startswith("f_"): + if repo_name.startswith("fp_"): t_fp_cmd.append( [ "flatpak", From 44d8729c7ee286994fad740e074c65505ade3d96 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 8 Jan 2023 23:43:54 +0800 Subject: [PATCH 142/240] include warning --- src/utils/core/gpu_install.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/core/gpu_install.py b/src/utils/core/gpu_install.py index 7203d6e..a975663 100644 --- a/src/utils/core/gpu_install.py +++ b/src/utils/core/gpu_install.py @@ -9,6 +9,11 @@ from src.utils.shared.log.logger import Logger +#! THIS IS EXPERIMENTAL AND NOT TESTED DUE TO LACK OF HARDWARE +#! SHOULD NOT BE CALLED YET ON THE MAIN FUNCTION IN MAIN.PY +#! ALTHOUGH THIS CAN BE ENABLED USING A FLAG `ex` IN THE CLI +#! BUT NOT IN DEFAULT OPTIONS, DO IT IN YOUR OWN DISCRETION + def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: """Fetch the GPU of the system. From db67bc10c1a735baa2b8f73bb66281eebc0a79c1 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 8 Jan 2023 23:54:57 +0800 Subject: [PATCH 143/240] for disabling of system services/autostart programs --- src/utils/core/sys_opt.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/utils/core/sys_opt.py diff --git a/src/utils/core/sys_opt.py b/src/utils/core/sys_opt.py new file mode 100644 index 0000000..1479d54 --- /dev/null +++ b/src/utils/core/sys_opt.py @@ -0,0 +1,36 @@ +from rich.console import Console + +from src.utils.shared.exec import exec_cmd +from src.utils.shared.misc.uinput import uinput +from src.utils.shared.log.logger import Logger + + +def disable_services( + console: Console, log: Logger, verbose: bool = False + ) -> None: + """Disable autostart/systemd services that is not necessary + + Args: + console -- instance of console + log -- instance of logger + verbose -- whether to show the stdout of cmds + """ + + cmd_arr: list[list[str]] = [ + [ + "sudo", + "systemctl", + "disable", + "NetworkManager-wait-online.service" + ], + [ + "sudo", + "rm", + "/etc/xdg/autostart/org.gnome.Software.desktop" + ] + ] + + cmd: str + for cmd in cmd_arr: + if uinput(console, f"Execute: {cmd}", 1): + exec_cmd(log, cmd, verbose) From 71fcca058fa584f316d644d5feba93b0aebed011 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 8 Jan 2023 23:56:22 +0800 Subject: [PATCH 144/240] turn into a class only for system optimization --- src/utils/core/sys_opt.py | 53 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/utils/core/sys_opt.py b/src/utils/core/sys_opt.py index 1479d54..fef99cd 100644 --- a/src/utils/core/sys_opt.py +++ b/src/utils/core/sys_opt.py @@ -5,32 +5,35 @@ from src.utils.shared.log.logger import Logger -def disable_services( - console: Console, log: Logger, verbose: bool = False - ) -> None: - """Disable autostart/systemd services that is not necessary +class SysOpt: + """For system optimizations""" - Args: - console -- instance of console - log -- instance of logger - verbose -- whether to show the stdout of cmds - """ + def disable_services( + console: Console, log: Logger, verbose: bool = False + ) -> None: + """Disable autostart/systemd services that is not necessary - cmd_arr: list[list[str]] = [ - [ - "sudo", - "systemctl", - "disable", - "NetworkManager-wait-online.service" - ], - [ - "sudo", - "rm", - "/etc/xdg/autostart/org.gnome.Software.desktop" + Args: + console -- instance of console + log -- instance of logger + verbose -- whether to show the stdout of cmds + """ + + cmd_arr: list[list[str]] = [ + [ + "sudo", + "systemctl", + "disable", + "NetworkManager-wait-online.service" + ], + [ + "sudo", + "rm", + "/etc/xdg/autostart/org.gnome.Software.desktop" + ] ] - ] - cmd: str - for cmd in cmd_arr: - if uinput(console, f"Execute: {cmd}", 1): - exec_cmd(log, cmd, verbose) + cmd: str + for cmd in cmd_arr: + if uinput(console, f"Execute: {cmd}", 1): + exec_cmd(log, cmd, verbose) From 85fe78bad1d1ae898b13fe4cf2dfc7b81b0979df Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 8 Jan 2023 23:59:03 +0800 Subject: [PATCH 145/240] include constructor the constructor takes a parameters of log console verbose --- src/utils/core/sys_opt.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/utils/core/sys_opt.py b/src/utils/core/sys_opt.py index fef99cd..15bd0c8 100644 --- a/src/utils/core/sys_opt.py +++ b/src/utils/core/sys_opt.py @@ -8,17 +8,24 @@ class SysOpt: """For system optimizations""" - def disable_services( - console: Console, log: Logger, verbose: bool = False + def __init__( + self, log: Logger, console: Console, verbose: bool = False ) -> None: - """Disable autostart/systemd services that is not necessary - + """ Args: - console -- instance of console log -- instance of logger + console -- instance of console verbose -- whether to show the stdout of cmds """ + self.log: Logger = log + self.console: Console = console + + self.verbose: bool = verbose + + def disable_services(self) -> None: + """Disable autostart/systemd services that is not necessary""" + cmd_arr: list[list[str]] = [ [ "sudo", @@ -35,5 +42,5 @@ def disable_services( cmd: str for cmd in cmd_arr: - if uinput(console, f"Execute: {cmd}", 1): - exec_cmd(log, cmd, verbose) + if uinput(self.console, f"Execute: {cmd}", 1): + exec_cmd(self.log, cmd, self.verbose) From d342931debbd879be83fef8e7a67a0ce1225acaf Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 00:01:55 +0800 Subject: [PATCH 146/240] initial commit on disabling of ssd workqueue --- src/utils/core/sys_opt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/core/sys_opt.py b/src/utils/core/sys_opt.py index 15bd0c8..0594cd3 100644 --- a/src/utils/core/sys_opt.py +++ b/src/utils/core/sys_opt.py @@ -44,3 +44,7 @@ def disable_services(self) -> None: for cmd in cmd_arr: if uinput(self.console, f"Execute: {cmd}", 1): exec_cmd(self.log, cmd, self.verbose) + + def disable_workqueue(self): + """Disable workqueue to improve ssd performance""" + ... From 7a78c5a004e88d3167807615cc48f4ed7b2bf979 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 13:47:04 +0800 Subject: [PATCH 147/240] change shell and finalization initial commit --- src/utils/core/change_shell.py | 1 + src/utils/core/finalization.py | 0 2 files changed, 1 insertion(+) create mode 100644 src/utils/core/change_shell.py create mode 100644 src/utils/core/finalization.py diff --git a/src/utils/core/change_shell.py b/src/utils/core/change_shell.py new file mode 100644 index 0000000..b2e54d2 --- /dev/null +++ b/src/utils/core/change_shell.py @@ -0,0 +1 @@ +# def change_shell(log: Logger) diff --git a/src/utils/core/finalization.py b/src/utils/core/finalization.py new file mode 100644 index 0000000..e69de29 From eead94e700e43bcc4717c1b2a2228a4cdc5f7955 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 13:51:59 +0800 Subject: [PATCH 148/240] include tainted rpmfusion for free and nonfree #6 --- src/utils/core/tp_repo_install.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index aa2d546..ffcfa0e 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -14,7 +14,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: tp_repo: dict[int, dict[str, str]] = { # id and name of the repo and the address 1: { - "name": "rpm_RPMFusion (Free)", + "name": "rpm_RPMFusion Free", "desc": "Fedora repository for open source softwares.", "address": ( r"https://mirrors.rpmfusion.org/" @@ -23,7 +23,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: ) }, 2: { - "name": "rpm_RPMFusion (Non-free)", + "name": "rpm_RPMFusion Non-free", "desc": "Fedora repository for propietary software.", "address": ( r"https://mirrors.rpmfusion.org/" @@ -55,6 +55,24 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: "https://nightly.gnome.org/" "gnome-nightly.flatpakrepo" ) + }, + 7: { + "name": "rpm_RPMFusion Free (Tainted)", + "desc": ( + "Software that use a free license, but may" + " have usage restriction in some countries" + ), + "address": "rpmfusion-free-release-tainted" + }, + 8: { + "name": "rpm_RPMFusion Non-free (Tainted)", + "desc": ( + "Software that uses a nonfree license and " + "which is not explicitly redistributable, " + "but is allowed for inter-operability " + "purposes in some countries." + ), + "address": "rpmfusion-nonfree-release-tainted" } } From a1a5923300f3f3bc76b2815695e0cbf35d4c4385 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 13:54:03 +0800 Subject: [PATCH 149/240] update desc of rpmfusion free and nonfree from official faq of rpmfusion --- src/utils/core/tp_repo_install.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index ffcfa0e..c4dcb5a 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -15,7 +15,10 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: # id and name of the repo and the address 1: { "name": "rpm_RPMFusion Free", - "desc": "Fedora repository for open source softwares.", + "desc": ( + "Software that uses a free license, but is " + "not accepted in Fedora for various reasons." + ), "address": ( r"https://mirrors.rpmfusion.org/" r"free/fedora/rpmfusion-free-release" @@ -24,7 +27,10 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: }, 2: { "name": "rpm_RPMFusion Non-free", - "desc": "Fedora repository for propietary software.", + "desc": ( + "Software that uses a nonfree " + "license, but is otherwise redistributable." + ), "address": ( r"https://mirrors.rpmfusion.org/" r"nonfree/fedora/rpmfusion-nonfree" From 5047d89daba2ebcab794ece6c198e21de1266320 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 13:55:59 +0800 Subject: [PATCH 150/240] fill the desc of fedora oci flatpak repo --- src/utils/core/tp_repo_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/tp_repo_install.py index c4dcb5a..0417a92 100644 --- a/src/utils/core/tp_repo_install.py +++ b/src/utils/core/tp_repo_install.py @@ -44,7 +44,7 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: }, 4: { "name": "fp_Fedora OCI", - "desc": "", #? what's this for?, + "desc": "For Open Containers Initiative (OCI)", #? what's this for? "address": "oci+https://registry.fedoraproject.org" }, 5: { From 1c2eef127af0c5b23f8489b67c3b063816b3ff7d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 13:58:29 +0800 Subject: [PATCH 151/240] initial commit for #15 --- src/utils/core/codecs.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/codecs.py diff --git a/src/utils/core/codecs.py b/src/utils/core/codecs.py new file mode 100644 index 0000000..e69de29 From cc2f6c44a7eec011cbdc83061268691996a4c028 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 9 Jan 2023 14:03:04 +0800 Subject: [PATCH 152/240] create a method for de based optimizations this method gives a specific command/tasks that is exclusive for particular de --- src/utils/core/sys_opt.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/utils/core/sys_opt.py b/src/utils/core/sys_opt.py index 0594cd3..7651910 100644 --- a/src/utils/core/sys_opt.py +++ b/src/utils/core/sys_opt.py @@ -1,6 +1,7 @@ from rich.console import Console from src.utils.shared.exec import exec_cmd +from src.utils.shared.fetch_env import fetch_env from src.utils.shared.misc.uinput import uinput from src.utils.shared.log.logger import Logger @@ -33,11 +34,6 @@ def disable_services(self) -> None: "disable", "NetworkManager-wait-online.service" ], - [ - "sudo", - "rm", - "/etc/xdg/autostart/org.gnome.Software.desktop" - ] ] cmd: str @@ -45,6 +41,28 @@ def disable_services(self) -> None: if uinput(self.console, f"Execute: {cmd}", 1): exec_cmd(self.log, cmd, self.verbose) + def de_based_opt(self) -> None: + """For disabling of autostart exclusive on specific de""" + match fetch_env( + self.log, self.console, "XDG_SESSION_DESKTOP" + ).lower(): + case "gnome": + cmd_arr: list[list[str]] = [ + [ + "sudo", + "rm", + "/etc/xdg/autostart/org.gnome.Software.desktop" + ] + ] + case "kde": + ... # disable baloo + case _: + return None + + for cmd in cmd_arr: + if uinput(self.console, f"Execute: {cmd}", 1): + exec_cmd(self.log, cmd, self.verbose) + def disable_workqueue(self): """Disable workqueue to improve ssd performance""" ... From a871f896a732a54f9baffe294598b6219a55e283 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 12 Jan 2023 21:49:55 +0800 Subject: [PATCH 153/240] include conf_link as parameter for user defined values --- src/utils/conf/fetch_config.py | 35 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index ec01291..9844b3e 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -6,7 +6,10 @@ def fetch_missing_config( - log: Logger, conf_name: str, CONF_PATH: str + log: Logger, + conf_name: str, + CONF_PATH: str, + conf_links: dict[str, str] = None ) -> None | NoReturn: """Downloads the original config file from github if not found. @@ -14,22 +17,24 @@ def fetch_missing_config( log -- instance of Logger conf_name -- name of the missing config CONF_PATH -- path of the config file + conf_links -- links of config files """ - conf_links: dict[str, str] = { - "app_for_install": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_install.json" - ), - "app_for_removal": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_removal.json" - ), - "ostree_setup": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/ostree_setup.json" - ) - } + if not conf_links: + conf_links = { + "app_for_install": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_install.json" + ), + "app_for_removal": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/app_for_removal.json" + ), + "ostree_setup": ( + "https://raw.githubusercontent.com/iaacornus/Fedora-" + "OSTree-Setup/devel/config/ostree_setup.json" + ) + } attempt: int for attempt in range(3): From 9ba0727080a84c2fed186e86129284031577b48f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Thu, 12 Jan 2023 21:52:47 +0800 Subject: [PATCH 154/240] default links to app_for_install & app_for_uninstall --- config/ostree_setup.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index e69de29..9511f55 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -0,0 +1,4 @@ +{ + "app_for_install_conf": "https://raw.githubusercontent.com/iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", + "app_for_uninstall_conf": "https://raw.githubusercontent.com/iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json" +} From 3b17f9f400e1f43ec95ea44776a5f37882c41a89 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:13:39 +0800 Subject: [PATCH 155/240] contributing.md for first time contributors --- CONTRIBUTING.md | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c155c2a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# Contribution + +All pull requests are welcome, however, do note that the maintainer of the +project is a full time university student, thus may not be able to respond as +fast as you may expect. + +# Notes + +1. If you are planning to introduce a big change in codebase, open an issue +first for discussion, that waste of time would be avoided. + +2. The project is currently written in Python 3.10, with strict compliance to +[PEP-0008](https://peps.python.org/pep-0008/) in terms of formatting, and to +[PEP-0257](https://peps.python.org/pep-0257/) in regards of docstring +formatting, with slight modification for sake of consistency: + +The modifications include: + +In lists, as well as declaration of variables, there is always indent after +line break: + +```python +hello_world: list[str] = [ + "a", "b", "c", + "d", "e", "f", + ..., + ] + +# not this one +hello_world: list[str] = [ + "a", "b", "c", + "d", "e", "f", + ..., +] + +"""However, in process calls, indent is not required""" +hello_from_long_function( + "arguments", "argument_2", "argument_3" +) +``` + +Rules to type checking is provided by [PEP-0484](https://peps.python.org/pep-0484/), +and is checked by [`mypy`](https://github.com/python/mypy), which requires +`type-setuptools` and `type-requests`. + +3. Be sure to run the unit tests and test your code first before opening pull +requests, the unit test can be invoked with +[`pytest`](https://github.com/pytest-dev/pytest/): `python -m pytest tests/tests.py`. + +4. Always comply to [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md). From 94eb8e2f9e4ca644aab27c739867d43722721f81 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:14:38 +0800 Subject: [PATCH 156/240] code of conduct for new contributors --- CODE_OF_CONDUCT.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..03ea9d2 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,28 @@ +# Code of Conduct + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org From 6a2257212456162a4b78c4d6293055ce3ba0c09b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:22:22 +0800 Subject: [PATCH 157/240] guidelines for how to start working in project --- HACKING.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 HACKING.md diff --git a/HACKING.md b/HACKING.md new file mode 100644 index 0000000..40cf538 --- /dev/null +++ b/HACKING.md @@ -0,0 +1,46 @@ +# HACKING + +To setup the project, clone the `devel` branch of the repository and create +your own branch with the name of feature/issue you want to introduce/work on: + +``` +git clone -b devel https://github.com/iaacornus/Fedora-OSTree-Setup +``` + +Then + +``` +git branch +``` + +The project is using Python >= 3.10, preferrably 3.11, thus to start working on +check if you have Python >= 3.10 with: + +``` +python --version +``` + +Although there can be workarounds, it is encouraged to use Python 3.10, but if not +possible, it is not enforced, upto Python >= 3.7 is acceptable. Then create a +virtual environment with + +``` +python -m venv venv +``` + +Source it and start installing dependencies with + +``` +pip install -r DEV_REQUIREMENTS && pip install -r REQUIREMENTS +``` + +_Note that in other system `pip3` or `pip` is used instead, +e.g. `pip3.11`._ + +`DEV_REQUIREMENTS` include the modules needed for test, specifically `mypy` and +the `types` of other third party modules, while `REQUIREMENTS` contains the +modules used by project. + +Finally start working in the project, refer to [CONTRIBUTING.md](CONTRIBUTING.md) +for guidelines about code formatting and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) +for acceptable interactions with in the community. From f38e2b5b3f1a40721d46a7590bf6d7579dfdddac Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:25:33 +0800 Subject: [PATCH 158/240] include contributing section in readme and update program description --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 085d85d..8140385 100755 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # Fedora-OSTree-Setup -A small program making the install of Fedora Silverblue / Kionite easy. It lets you choose what to install or set. + +A python-program that automates the setup of Fedora Silverblue/Kinoite based +on given config file. + +# Contributing + +All contributions whether small or large is welcome! Just fork the project and +create a pull request when done. + +Refer to [HACKING.md](HACKING.md) to start in how to setup the project, then in +[CONTRIBUTING.md](CONTRIBUTING.md) for protocols/guidelines to follow, and take +a browse in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) to see what is the acceptable +behavior in the community. From 7b48b3365de18206acabe774b0ecc4288357182c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:27:07 +0800 Subject: [PATCH 159/240] update information in contributing.md --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c155c2a..785bda9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ hello_world: list[str] = [ ..., ] -"""However, in process calls, indent is not required""" +"""However, in function calls, indent is not required""" hello_from_long_function( "arguments", "argument_2", "argument_3" ) @@ -43,8 +43,7 @@ Rules to type checking is provided by [PEP-0484](https://peps.python.org/pep-048 and is checked by [`mypy`](https://github.com/python/mypy), which requires `type-setuptools` and `type-requests`. -3. Be sure to run the unit tests and test your code first before opening pull -requests, the unit test can be invoked with -[`pytest`](https://github.com/pytest-dev/pytest/): `python -m pytest tests/tests.py`. +3. Be sure to run the checks and test your code first before opening pull +requests, the unit test can be invoked with `./check.sh`. 4. Always comply to [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md). From 1f0143a6aa50cddcb27d928c2fe9dc128ce51348 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:31:03 +0800 Subject: [PATCH 160/240] include notes --- HACKING.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/HACKING.md b/HACKING.md index 40cf538..3d99fa6 100644 --- a/HACKING.md +++ b/HACKING.md @@ -44,3 +44,42 @@ modules used by project. Finally start working in the project, refer to [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines about code formatting and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for acceptable interactions with in the community. + +# Notes + +1. All functions are documented with docstrings, [PEP 0257](https://peps.python.org/pep-0257/), +which takes a format of: + +```python +def function(x: int) -> int: + """This is an example of long documentation. + + Args: + x -- any number + + Returns: + Square of the given number, x. + """ + + return x*x +``` + +Then for a short docstring: + +```python +def function(x: int) -> int: + """"Square a number.""" + + return x*x +``` + +2. Use comments, preferrably if you can use the Better Comments syntax, please do: + +``` +#! FOR URGENT/WARNING +#? IMPORTANT +#* NOTICE +# TODO: THINGS THAT SHOULD BE DONE +``` + + From bb79041960eada27ef73b9e46381ecc37d7d523a Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:47:23 +0800 Subject: [PATCH 161/240] include more notes --- HACKING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HACKING.md b/HACKING.md index 3d99fa6..2f30273 100644 --- a/HACKING.md +++ b/HACKING.md @@ -82,4 +82,5 @@ def function(x: int) -> int: # TODO: THINGS THAT SHOULD BE DONE ``` - +3. Browse `/docs/` for further documentation of the project structure, +functions, classes and the code itself. From 1f7b3ea3f4af86c29c88a915319326dc736d7988 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:48:42 +0800 Subject: [PATCH 162/240] initial commit in documentation --- docs/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..7a22262 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# DOCUMENTATION + +This directory contains all the documentation about the project codebase. From 48112bd4c71e8daac96cb68c214aa1ffbaa2d5da Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 22:56:32 +0800 Subject: [PATCH 163/240] documentation about structure of the project --- docs/project_struct.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/project_struct.md diff --git a/docs/project_struct.md b/docs/project_struct.md new file mode 100644 index 0000000..eea4ef2 --- /dev/null +++ b/docs/project_struct.md @@ -0,0 +1,39 @@ +# Structure + +The project has an structure of: + +``` +src ++-- interface ++-- misc +`-- utils + +-- conf + +-- core + `-- shared + +-- log + `-- misc +``` + +`src/` contains the source code of the program, which is further broken down into: + +1. `interface`, where the front-end related codes are stored, particularly +the commandline interface. + +2. `misc` are where the not really important codes are stored such as type aliases. + +3. `utils` where the functions that is called in `main.py` is stored, which is +further broken down into: + +a. `conf` are everything related to the functions that deal with the config +file of the program. + +b. `core` are the most crucial piece that executes each feature such as +removal of applications as well as installation. + +c. `shared` are where the self written modules called by different modules in +`core` are stored, this is further broken down into: + +1. `log`, the logging system. + +2. `misc`, are another not really important codes, although plays a +crucial role. From 7821dc3f2dc20ba101dd87ca272d12ac19cb4e07 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 23:09:14 +0800 Subject: [PATCH 164/240] for system optimization --- src/utils/core/optimizations/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/optimizations/__init__.py diff --git a/src/utils/core/optimizations/__init__.py b/src/utils/core/optimizations/__init__.py new file mode 100644 index 0000000..e69de29 From 36a01bdf2f16f614343bb3ff8f221d7e4dd8d639 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 23:09:48 +0800 Subject: [PATCH 165/240] for program installation and removal --- src/utils/core/programs/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/programs/__init__.py diff --git a/src/utils/core/programs/__init__.py b/src/utils/core/programs/__init__.py new file mode 100644 index 0000000..e69de29 From 82013122f2c20151781174ff35bc3eb89880b3ef Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 23:10:17 +0800 Subject: [PATCH 166/240] for system wide changes --- src/utils/core/system/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/system/__init__.py diff --git a/src/utils/core/system/__init__.py b/src/utils/core/system/__init__.py new file mode 100644 index 0000000..e69de29 From 412adad8fa6c3f24ee99a50f128b87935ff538b4 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 23:11:19 +0800 Subject: [PATCH 167/240] for drivers and codecs --- src/utils/core/drv_codecs/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/drv_codecs/__init__.py diff --git a/src/utils/core/drv_codecs/__init__.py b/src/utils/core/drv_codecs/__init__.py new file mode 100644 index 0000000..e69de29 From d46e8394dd8f55a122ba4f388c49d64c2273f27a Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 23 Jan 2023 23:13:01 +0800 Subject: [PATCH 168/240] restructure utils.core --- src/utils/core/{ => drv_codecs}/codecs.py | 0 src/utils/core/{ => drv_codecs}/gpu_install.py | 0 src/utils/core/{ => programs}/add_remove.py | 0 src/utils/core/{ => programs}/tp_repo_install.py | 0 src/utils/core/{ => system}/change_shell.py | 0 src/utils/core/{ => system}/optimizations/__init__.py | 0 src/utils/core/{ => system/optimizations}/sys_opt.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename src/utils/core/{ => drv_codecs}/codecs.py (100%) rename src/utils/core/{ => drv_codecs}/gpu_install.py (100%) rename src/utils/core/{ => programs}/add_remove.py (100%) rename src/utils/core/{ => programs}/tp_repo_install.py (100%) rename src/utils/core/{ => system}/change_shell.py (100%) rename src/utils/core/{ => system}/optimizations/__init__.py (100%) rename src/utils/core/{ => system/optimizations}/sys_opt.py (100%) diff --git a/src/utils/core/codecs.py b/src/utils/core/drv_codecs/codecs.py similarity index 100% rename from src/utils/core/codecs.py rename to src/utils/core/drv_codecs/codecs.py diff --git a/src/utils/core/gpu_install.py b/src/utils/core/drv_codecs/gpu_install.py similarity index 100% rename from src/utils/core/gpu_install.py rename to src/utils/core/drv_codecs/gpu_install.py diff --git a/src/utils/core/add_remove.py b/src/utils/core/programs/add_remove.py similarity index 100% rename from src/utils/core/add_remove.py rename to src/utils/core/programs/add_remove.py diff --git a/src/utils/core/tp_repo_install.py b/src/utils/core/programs/tp_repo_install.py similarity index 100% rename from src/utils/core/tp_repo_install.py rename to src/utils/core/programs/tp_repo_install.py diff --git a/src/utils/core/change_shell.py b/src/utils/core/system/change_shell.py similarity index 100% rename from src/utils/core/change_shell.py rename to src/utils/core/system/change_shell.py diff --git a/src/utils/core/optimizations/__init__.py b/src/utils/core/system/optimizations/__init__.py similarity index 100% rename from src/utils/core/optimizations/__init__.py rename to src/utils/core/system/optimizations/__init__.py diff --git a/src/utils/core/sys_opt.py b/src/utils/core/system/optimizations/sys_opt.py similarity index 100% rename from src/utils/core/sys_opt.py rename to src/utils/core/system/optimizations/sys_opt.py From 91185d4d7a08f02cc8469449b6276b2fc8ab96c4 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 21:50:45 +0800 Subject: [PATCH 169/240] change t_rpm_prog from list[str] to dict[str, list[str]] this allow to further accomodate whether the program was from rpmfusion free or rpmfusion nonfree to main repo, which would allow for further decision on whether to install the rpmfusion repos or not. --- src/utils/core/programs/add_remove.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 20ca87d..6c81d7a 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -87,7 +87,11 @@ def setup(self) -> tuple[list[list[str]], list[str]]: """For add/remove of recommended program selected by user.""" t_fp_cmd: list[list[str]] = [] - t_rpm_prog: list[str] = [] + t_rpm_prog: dict[str, list[str]] = { + "m_repo": [], #* main repo + "rf_free": [], #* rpmfusion free + "rf_nfree": [] #* rpmfusion nonfree + } # fp_ind -> flatpak programs ind # rappsindex -> rpm programs ind From 6063bcb62b9e7b54e0774f4ad3afb177d3f393ad Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 21:55:07 +0800 Subject: [PATCH 170/240] include source parameter that specify the repository of the program --- config/app_for_install.json | 116 +++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 40 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 4977318..8149c83 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -1,154 +1,190 @@ -[ - { +{ + "flatpak": { "Mailspring": { "aid": "com.getmailspring.Mailspring", - "sdesc": "A simple email client." + "sdesc": "A simple email client.", + "source": "flatpak" }, "LibreOffice": { "aid": "org.libreoffice.LibreOffice", - "sdesc": "Office suite." + "sdesc": "Office suite.", + "source": "flatpak" }, "VLC": { "aid": "org.videolan.VLC", - "sdesc": "Video player." + "sdesc": "Video player.", + "source": "flatpak" }, "Okular": { "aid": "org.kde.okular", - "sdesc": "A document viewer." + "sdesc": "A document viewer.", + "source": "flatpak" }, "GIMP": { "aid": "org.gimp.GIMP", - "sdesc": "Photo editing application." + "sdesc": "Photo editing application.", + "source": "flatpak" }, "ClamTk": { "aid": "com.gitlab.davem.ClamTk", - "sdesc": "Front end for ClamAV." + "sdesc": "Front end for ClamAV.", + "source": "flatpak" }, "FlatSeal": { "aid": "com.github.tchx84.Flatseal", - "sdesc": "GUI for managing flatpak applications permission" + "sdesc": "GUI for managing flatpak applications permission", + "source": "flatpak" }, "KeepassXC": { "aid": "org.keepassxc.KeePassXC", - "sdesc": "Secure Password manager." + "sdesc": "Secure Password manager.", + "source": "flatpak" }, "Cryptomator": { "aid": "org.cryptomator.Cryptomator", - "sdesc": "Secure and easy encryption, especially for Cloud storages." + "sdesc": "Secure and easy encryption, especially for Cloud storages.", + "source": "flatpak" }, "Easy-Effects": { "aid": "com.github.wwmm.easyeffects", - "sdesc": "Modify your PulseAudio sound" + "sdesc": "Modify your PulseAudio sound", + "source": "flatpak" }, "Sync-Thingy": { "aid": "com.github.zocker_160.SyncThingy", - "sdesc": "Sync folders securely between devices, no server." + "sdesc": "Sync folders securely between devices, no server.", + "source": "flatpak" }, "XNView MP": { "aid": "com.xnview.XnViewMP", - "sdesc": "Image Viewer and editor with many functions" + "sdesc": "Image Viewer and editor with many functions", + "source": "flatpak" }, "Freetube": { "aid": "io.freetubeapp.FreeTube", - "sdesc": "Watch YouTube privately with local subscriptions and playlists." + "sdesc": "Watch YouTube privately with local subscriptions and playlists.", + "source": "flatpak" }, "Inkscape": { "aid": "org.inkscape.Inkscape", - "sdesc": "A Vector graphics program" + "sdesc": "A Vector graphics program", + "source": "flatpak" }, "GNOME Boxen": { "aid": "org.gnome.Boxes", - "sdesc": "Manage fast Virtual machines with a simple interface." + "sdesc": "Manage fast Virtual machines with a simple interface.", + "source": "flatpak" }, "Filelight": { "aid": "org.kde.filelight ", - "sdesc": "View what files consume how much space in a pie chart." + "sdesc": "View what files consume how much space in a pie chart.", + "source": "flatpak" }, "Kdenlive": { "aid": "org.kde.kdenlive", - "sdesc": "Video cut program" + "sdesc": "Video cut program", + "source": "flatpak" }, "Onion Share": { "aid": "org.onionshare.OnionShare", - "sdesc": "Share files, chat and create websites over Tor" + "sdesc": "Share files, chat and create websites over Tor", + "source": "flatpak" }, "qBittorrent": { "aid": "org.qbittorrent.qBittorrent", - "sdesc": "Share files decentral with a big community." + "sdesc": "Share files decentral with a big community.", + "source": "flatpak" }, "Metadata-cleaner": { "aid": "fr.romainvigier.MetadataCleaner", "sdesc": "Easily remove all identifying information on Images using exiftool." - } + }, + "source": "flatpak" }, - { + "rpm": { "exiftool": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "perl-Image-ExifTool": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "clamtk*": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "fail2ban": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "tlp": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "make": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "gcc-c++": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "qemu-kvm": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "qemu-img": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "qemu-user-static": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "ffmpegthumbs": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "kffmpegthumbnailer": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "unrar": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "stacer": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "python-pip": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "android-tools": { "aid": "", - "sdesc": "" + "sdesc": "", + "source": "" }, "btfs": { "aid": "", "sdesc": "" } } -] +} From a531f42c2e889641032ab72647a6dd226595290f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 21:56:27 +0800 Subject: [PATCH 171/240] merge the two dictionary and include source parameter the source parameter specifies the repository where the app would be fetched, e.g. flathub/flatpak, rpmfusion nonfree, or rpmfusion free. --- config/app_for_install.json | 373 ++++++++++++++++++------------------ config/app_for_removal.json | 260 +++++++++++++------------ 2 files changed, 327 insertions(+), 306 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 8149c83..6a94ea7 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -1,190 +1,187 @@ { - "flatpak": { - "Mailspring": { - "aid": "com.getmailspring.Mailspring", - "sdesc": "A simple email client.", - "source": "flatpak" - }, - "LibreOffice": { - "aid": "org.libreoffice.LibreOffice", - "sdesc": "Office suite.", - "source": "flatpak" - }, - "VLC": { - "aid": "org.videolan.VLC", - "sdesc": "Video player.", - "source": "flatpak" - }, - "Okular": { - "aid": "org.kde.okular", - "sdesc": "A document viewer.", - "source": "flatpak" - }, - "GIMP": { - "aid": "org.gimp.GIMP", - "sdesc": "Photo editing application.", - "source": "flatpak" - }, - "ClamTk": { - "aid": "com.gitlab.davem.ClamTk", - "sdesc": "Front end for ClamAV.", - "source": "flatpak" - }, - "FlatSeal": { - "aid": "com.github.tchx84.Flatseal", - "sdesc": "GUI for managing flatpak applications permission", - "source": "flatpak" - }, - "KeepassXC": { - "aid": "org.keepassxc.KeePassXC", - "sdesc": "Secure Password manager.", - "source": "flatpak" - }, - "Cryptomator": { - "aid": "org.cryptomator.Cryptomator", - "sdesc": "Secure and easy encryption, especially for Cloud storages.", - "source": "flatpak" - }, - "Easy-Effects": { - "aid": "com.github.wwmm.easyeffects", - "sdesc": "Modify your PulseAudio sound", - "source": "flatpak" - }, - "Sync-Thingy": { - "aid": "com.github.zocker_160.SyncThingy", - "sdesc": "Sync folders securely between devices, no server.", - "source": "flatpak" - }, - "XNView MP": { - "aid": "com.xnview.XnViewMP", - "sdesc": "Image Viewer and editor with many functions", - "source": "flatpak" - }, - "Freetube": { - "aid": "io.freetubeapp.FreeTube", - "sdesc": "Watch YouTube privately with local subscriptions and playlists.", - "source": "flatpak" - }, - "Inkscape": { - "aid": "org.inkscape.Inkscape", - "sdesc": "A Vector graphics program", - "source": "flatpak" - }, - "GNOME Boxen": { - "aid": "org.gnome.Boxes", - "sdesc": "Manage fast Virtual machines with a simple interface.", - "source": "flatpak" - }, - "Filelight": { - "aid": "org.kde.filelight ", - "sdesc": "View what files consume how much space in a pie chart.", - "source": "flatpak" - }, - "Kdenlive": { - "aid": "org.kde.kdenlive", - "sdesc": "Video cut program", - "source": "flatpak" - }, - "Onion Share": { - "aid": "org.onionshare.OnionShare", - "sdesc": "Share files, chat and create websites over Tor", - "source": "flatpak" - }, - "qBittorrent": { - "aid": "org.qbittorrent.qBittorrent", - "sdesc": "Share files decentral with a big community.", - "source": "flatpak" - }, - "Metadata-cleaner": { - "aid": "fr.romainvigier.MetadataCleaner", - "sdesc": "Easily remove all identifying information on Images using exiftool." - }, - "source": "flatpak" - }, - "rpm": { - "exiftool": { - "aid": "", - "sdesc": "", - "source": "" - }, - "perl-Image-ExifTool": { - "aid": "", - "sdesc": "", - "source": "" - }, - "clamtk*": { - "aid": "", - "sdesc": "", - "source": "" - }, - "fail2ban": { - "aid": "", - "sdesc": "", - "source": "" - }, - "tlp": { - "aid": "", - "sdesc": "", - "source": "" - }, - "make": { - "aid": "", - "sdesc": "", - "source": "" - }, - "gcc-c++": { - "aid": "", - "sdesc": "", - "source": "" - }, - "qemu-kvm": { - "aid": "", - "sdesc": "", - "source": "" - }, - "qemu-img": { - "aid": "", - "sdesc": "", - "source": "" - }, - "qemu-user-static": { - "aid": "", - "sdesc": "", - "source": "" - }, - "ffmpegthumbs": { - "aid": "", - "sdesc": "", - "source": "" - }, - "kffmpegthumbnailer": { - "aid": "", - "sdesc": "", - "source": "" - }, - "unrar": { - "aid": "", - "sdesc": "", - "source": "" - }, - "stacer": { - "aid": "", - "sdesc": "", - "source": "" - }, - "python-pip": { - "aid": "", - "sdesc": "", - "source": "" - }, - "android-tools": { - "aid": "", - "sdesc": "", - "source": "" - }, - "btfs": { - "aid": "", - "sdesc": "" - } - } + "Mailspring": { + "aid": "com.getmailspring.Mailspring", + "sdesc": "A simple email client.", + "source": "flatpak" + }, + "LibreOffice": { + "aid": "org.libreoffice.LibreOffice", + "sdesc": "Office suite.", + "source": "flatpak" + }, + "VLC": { + "aid": "org.videolan.VLC", + "sdesc": "Video player.", + "source": "flatpak" + }, + "Okular": { + "aid": "org.kde.okular", + "sdesc": "A document viewer.", + "source": "flatpak" + }, + "GIMP": { + "aid": "org.gimp.GIMP", + "sdesc": "Photo editing application.", + "source": "flatpak" + }, + "ClamTk": { + "aid": "com.gitlab.davem.ClamTk", + "sdesc": "Front end for ClamAV.", + "source": "flatpak" + }, + "FlatSeal": { + "aid": "com.github.tchx84.Flatseal", + "sdesc": "GUI for managing flatpak applications permission", + "source": "flatpak" + }, + "KeepassXC": { + "aid": "org.keepassxc.KeePassXC", + "sdesc": "Secure Password manager.", + "source": "flatpak" + }, + "Cryptomator": { + "aid": "org.cryptomator.Cryptomator", + "sdesc": "Secure and easy encryption, especially for Cloud storages.", + "source": "flatpak" + }, + "Easy-Effects": { + "aid": "com.github.wwmm.easyeffects", + "sdesc": "Modify your PulseAudio sound", + "source": "flatpak" + }, + "Sync-Thingy": { + "aid": "com.github.zocker_160.SyncThingy", + "sdesc": "Sync folders securely between devices, no server.", + "source": "flatpak" + }, + "XNView MP": { + "aid": "com.xnview.XnViewMP", + "sdesc": "Image Viewer and editor with many functions", + "source": "flatpak" + }, + "Freetube": { + "aid": "io.freetubeapp.FreeTube", + "sdesc": "Watch YouTube privately with local subscriptions and playlists.", + "source": "flatpak" + }, + "Inkscape": { + "aid": "org.inkscape.Inkscape", + "sdesc": "A Vector graphics program", + "source": "flatpak" + }, + "GNOME Boxen": { + "aid": "org.gnome.Boxes", + "sdesc": "Manage fast Virtual machines with a simple interface.", + "source": "flatpak" + }, + "Filelight": { + "aid": "org.kde.filelight ", + "sdesc": "View what files consume how much space in a pie chart.", + "source": "flatpak" + }, + "Kdenlive": { + "aid": "org.kde.kdenlive", + "sdesc": "Video cut program", + "source": "flatpak" + }, + "Onion Share": { + "aid": "org.onionshare.OnionShare", + "sdesc": "Share files, chat and create websites over Tor", + "source": "flatpak" + }, + "qBittorrent": { + "aid": "org.qbittorrent.qBittorrent", + "sdesc": "Share files decentral with a big community.", + "source": "flatpak" + }, + "Metadata-cleaner": { + "aid": "fr.romainvigier.MetadataCleaner", + "sdesc": "Easily remove all identifying information on Images using exiftool.", + "source": "flatpak" + }, + "exiftool": { + "aid": "", + "sdesc": "", + "source": "" + }, + "perl-Image-ExifTool": { + "aid": "", + "sdesc": "", + "source": "" + }, + "clamtk*": { + "aid": "", + "sdesc": "", + "source": "" + }, + "fail2ban": { + "aid": "", + "sdesc": "", + "source": "" + }, + "tlp": { + "aid": "", + "sdesc": "", + "source": "" + }, + "make": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gcc-c++": { + "aid": "", + "sdesc": "", + "source": "" + }, + "qemu-kvm": { + "aid": "", + "sdesc": "", + "source": "" + }, + "qemu-img": { + "aid": "", + "sdesc": "", + "source": "" + }, + "qemu-user-static": { + "aid": "", + "sdesc": "", + "source": "" + }, + "ffmpegthumbs": { + "aid": "", + "sdesc": "", + "source": "" + }, + "kffmpegthumbnailer": { + "aid": "", + "sdesc": "", + "source": "" + }, + "unrar": { + "aid": "", + "sdesc": "", + "source": "" + }, + "stacer": { + "aid": "", + "sdesc": "", + "source": "" + }, + "python-pip": { + "aid": "", + "sdesc": "", + "source": "" + }, + "android-tools": { + "aid": "", + "sdesc": "", + "source": "" + }, + "btfs": { + "aid": "", + "sdesc": "", + "source": "" + } } diff --git a/config/app_for_removal.json b/config/app_for_removal.json index a9adea6..34923d4 100644 --- a/config/app_for_removal.json +++ b/config/app_for_removal.json @@ -1,118 +1,142 @@ -[ - { - "org.gnome.Calculator": { - "aid": "Calculator", - "sdesc": "" - }, - "org.gnome.Calendar": { - "aid": "Calendar", - "sdesc": "" - }, - "org.gnome.Characters": { - "aid": "Characters", - "sdesc": "" - }, - "org.gnome.Connections": { - "aid": "Connections", - "sdesc": "" - }, - "org.gnome.Contacts": { - "aid": "Contacts", - "sdesc": "" - }, - "org.gnome.Evince": { - "aid": "Evince", - "sdesc": "" - }, - "org.gnome.Extensions": { - "aid": "Extensions", - "sdesc": "" - }, - "org.gnome.Logs": { - "aid": "Logs", - "sdesc": "" - }, - "org.gnome.Maps": { - "aid": "Maps", - "sdesc": "" - }, - "org.gnome.TextEditor": { - "aid": "Text Editor", - "sdesc": "" - }, - "org.gnome.Weather": { - "aid": "Weather", - "sdesc": "" - }, - "org.gnome.baobab": { - "aid": "Disk Usage Analyzer", - "sdesc": "" - }, - "org.gnome.Clocks": { - "aid": "Clocks", - "sdesc": "" - }, - "org.gnome.eog": { - "aid": "Image Viewer", - "sdesc": "" - }, - "org.gnome.fonts-viewer": { - "aid": "Fonts Viewer", - "sdesc": "" - } - }, - { - "libavcodec-free": { - "aid": "", - "sdesc": "" - }, - "open-vm-tools-desktop": { - "aid": "", - "sdesc": "" - }, - "open-vm-tools": { - "aid": "", - "sdesc": "" - }, - "qemu-guest-agent": { - "aid": "", - "sdesc": "" - }, - "spice-vdagent": { - "aid": "", - "sdesc": "" - }, - "spice-webdavd": { - "aid": "", - "sdesc": "" - }, - "virtualbox-guest-additions": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-apps-menu": { - "aid": "", - "sdesc": "" - }, - "gnome-classic-session": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-window-list": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-background-logo": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-launch-new-instance": { - "aid": "", - "sdesc": "" - }, - "gnome-shell-extension-places-menu": { - "aid": "", - "sdesc": "" - } - } -] +{ + "org.gnome.Calculator": { + "aid": "Calculator", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Calendar": { + "aid": "Calendar", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Characters": { + "aid": "Characters", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Connections": { + "aid": "Connections", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Contacts": { + "aid": "Contacts", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Evince": { + "aid": "Evince", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Extensions": { + "aid": "Extensions", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Logs": { + "aid": "Logs", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Maps": { + "aid": "Maps", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.TextEditor": { + "aid": "Text Editor", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Weather": { + "aid": "Weather", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.baobab": { + "aid": "Disk Usage Analyzer", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.Clocks": { + "aid": "Clocks", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.eog": { + "aid": "Image Viewer", + "sdesc": "", + "source": "flatpak" + }, + "org.gnome.fonts-viewer": { + "aid": "Fonts Viewer", + "sdesc": "", + "source": "flatpak" + }, + "libavcodec-free": { + "aid": "", + "sdesc": "", + "source": "" + }, + "open-vm-tools-desktop": { + "aid": "", + "sdesc": "", + "source": "" + }, + "open-vm-tools": { + "aid": "", + "sdesc": "", + "source": "" + }, + "qemu-guest-agent": { + "aid": "", + "sdesc": "", + "source": "" + }, + "spice-vdagent": { + "aid": "", + "sdesc": "", + "source": "" + }, + "spice-webdavd": { + "aid": "", + "sdesc": "", + "source": "" + }, + "virtualbox-guest-additions": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gnome-shell-extension-apps-menu": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gnome-classic-session": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gnome-shell-extension-window-list": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gnome-shell-extension-background-logo": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gnome-shell-extension-launch-new-instance": { + "aid": "", + "sdesc": "", + "source": "" + }, + "gnome-shell-extension-places-menu": { + "aid": "", + "sdesc": "", + "source": "" + } +} From 4d7032caabc3e66a42f76be51ac0befc2a2652a2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 22:00:07 +0800 Subject: [PATCH 172/240] update type alias of progdata --- src/misc/alias.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/alias.py b/src/misc/alias.py index b170044..c40238c 100644 --- a/src/misc/alias.py +++ b/src/misc/alias.py @@ -1,4 +1,4 @@ -ProgData = dict[str, dict[str, str]] +ProgData = dict[str, dict[str, str, str]] ProgIndex = dict[int, str] ConfigValues = list[ list[dict[str, str | dict[str, str]]] | dict[str, str] From c79864770aa0cc2da3865a752b0b72968aa94810 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 22:36:38 +0800 Subject: [PATCH 173/240] broadly specify source for all rpm apps as rpm for testing purposes --- config/app_for_install.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 6a94ea7..67859da 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -102,86 +102,86 @@ "exiftool": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "perl-Image-ExifTool": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "clamtk*": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "fail2ban": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "tlp": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "make": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "gcc-c++": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "qemu-kvm": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "qemu-img": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "qemu-user-static": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "ffmpegthumbs": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "kffmpegthumbnailer": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "unrar": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "stacer": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "python-pip": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "android-tools": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" }, "btfs": { "aid": "", "sdesc": "", - "source": "" + "source": "rpm" } } From 7766f8122ad452f6fce67b290b65112e23cc3a8c Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 22:36:52 +0800 Subject: [PATCH 174/240] remove other parameters specific to flatpak and rpm --- src/utils/core/programs/add_remove.py | 36 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 6c81d7a..1314844 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -13,24 +13,40 @@ class ProgramSetup: def __init__( self, console: Console, - fp_data_arr: ProgData, - rpm_data_arr: ProgData, + prog_data: ProgData, action: str ) -> None: """ Args: console -- instance of Console - fp_data_arr -- lists of the recommended applications - including their application id (aid) and description - rpm_data_arr -- lists of the recommended applications - including their application id (aid) and description + prog_data -- the database of applications action -- whether uninstall or install """ self.console: Console = console - self.fp_PROGARR: ProgData = fp_data_arr - self.rpm_PROGARR: ProgData = rpm_data_arr + self.fp_PROGARR: ProgData = { + progname: { + "aid": proginfo.get("aid"), + "sdesc": proginfo.get("sdesc"), + "source": proginfo.get("source") + } for progname, proginfo in zip( + prog_data.keys(), prog_data.values() + ) + if proginfo.get("source").lower() == "flatpak" + } + self.rpm_PROGARR: ProgData = { + progname: { + "aid": proginfo.get("aid"), + "sdesc": proginfo.get("sdesc"), + "source": proginfo.get("source") + } for progname, proginfo in zip( + prog_data.keys(), prog_data.values() + ) + if proginfo.get("source").lower() in [ + "rpm", "rfusion_free", "rfusion_nfree" + ] + } self.action: str = action @@ -63,8 +79,8 @@ def _enum_prog( """ section( - f"{self.action}ion of recommended programs" - f"recommended programs ({progtype})", + f"{self.action}ion of recommended programs", + f"recommended programs ({progtype})" ) ind: int; progname: str From 6a32f072a0c4c9c4e16415f92fd0b032b9090e23 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 22:37:58 +0800 Subject: [PATCH 175/240] remove use of zip() in dictionary comprehension in sorting of program data --- src/utils/core/programs/add_remove.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 1314844..946647a 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -30,9 +30,7 @@ def __init__( "aid": proginfo.get("aid"), "sdesc": proginfo.get("sdesc"), "source": proginfo.get("source") - } for progname, proginfo in zip( - prog_data.keys(), prog_data.values() - ) + } for progname, proginfo in prog_data.items() if proginfo.get("source").lower() == "flatpak" } self.rpm_PROGARR: ProgData = { @@ -40,9 +38,7 @@ def __init__( "aid": proginfo.get("aid"), "sdesc": proginfo.get("sdesc"), "source": proginfo.get("source") - } for progname, proginfo in zip( - prog_data.keys(), prog_data.values() - ) + } for progname, proginfo in prog_data.items() if proginfo.get("source").lower() in [ "rpm", "rfusion_free", "rfusion_nfree" ] From 33620fec56089527e3531992ce8d5a320ae6be10 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Tue, 24 Jan 2023 22:39:12 +0800 Subject: [PATCH 176/240] test block for src.utils.core.programs.add_remove --- assets/test_block-app_remove | 190 +++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 assets/test_block-app_remove diff --git a/assets/test_block-app_remove b/assets/test_block-app_remove new file mode 100644 index 0000000..684f53d --- /dev/null +++ b/assets/test_block-app_remove @@ -0,0 +1,190 @@ + +app = { + "Mailspring": { + "aid": "com.getmailspring.Mailspring", + "sdesc": "A simple email client.", + "source": "flatpak" + }, + "LibreOffice": { + "aid": "org.libreoffice.LibreOffice", + "sdesc": "Office suite.", + "source": "flatpak" + }, + "VLC": { + "aid": "org.videolan.VLC", + "sdesc": "Video player.", + "source": "flatpak" + }, + "Okular": { + "aid": "org.kde.okular", + "sdesc": "A document viewer.", + "source": "flatpak" + }, + "GIMP": { + "aid": "org.gimp.GIMP", + "sdesc": "Photo editing application.", + "source": "flatpak" + }, + "ClamTk": { + "aid": "com.gitlab.davem.ClamTk", + "sdesc": "Front end for ClamAV.", + "source": "flatpak" + }, + "FlatSeal": { + "aid": "com.github.tchx84.Flatseal", + "sdesc": "GUI for managing flatpak applications permission", + "source": "flatpak" + }, + "KeepassXC": { + "aid": "org.keepassxc.KeePassXC", + "sdesc": "Secure Password manager.", + "source": "flatpak" + }, + "Cryptomator": { + "aid": "org.cryptomator.Cryptomator", + "sdesc": "Secure and easy encryption, especially for Cloud storages.", + "source": "flatpak" + }, + "Easy-Effects": { + "aid": "com.github.wwmm.easyeffects", + "sdesc": "Modify your PulseAudio sound", + "source": "flatpak" + }, + "Sync-Thingy": { + "aid": "com.github.zocker_160.SyncThingy", + "sdesc": "Sync folders securely between devices, no server.", + "source": "flatpak" + }, + "XNView MP": { + "aid": "com.xnview.XnViewMP", + "sdesc": "Image Viewer and editor with many functions", + "source": "flatpak" + }, + "Freetube": { + "aid": "io.freetubeapp.FreeTube", + "sdesc": "Watch YouTube privately with local subscriptions and playlists.", + "source": "flatpak" + }, + "Inkscape": { + "aid": "org.inkscape.Inkscape", + "sdesc": "A Vector graphics program", + "source": "flatpak" + }, + "GNOME Boxen": { + "aid": "org.gnome.Boxes", + "sdesc": "Manage fast Virtual machines with a simple interface.", + "source": "flatpak" + }, + "Filelight": { + "aid": "org.kde.filelight ", + "sdesc": "View what files consume how much space in a pie chart.", + "source": "flatpak" + }, + "Kdenlive": { + "aid": "org.kde.kdenlive", + "sdesc": "Video cut program", + "source": "flatpak" + }, + "Onion Share": { + "aid": "org.onionshare.OnionShare", + "sdesc": "Share files, chat and create websites over Tor", + "source": "flatpak" + }, + "qBittorrent": { + "aid": "org.qbittorrent.qBittorrent", + "sdesc": "Share files decentral with a big community.", + "source": "flatpak" + }, + "Metadata-cleaner": { + "aid": "fr.romainvigier.MetadataCleaner", + "sdesc": "Easily remove all identifying information on Images using exiftool.", + "source": "flatpak" + }, + "exiftool": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "perl-Image-ExifTool": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "clamtk*": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "fail2ban": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "tlp": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "make": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "gcc-c++": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "qemu-kvm": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "qemu-img": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "qemu-user-static": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "ffmpegthumbs": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "kffmpegthumbnailer": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "unrar": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "stacer": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "python-pip": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "android-tools": { + "aid": "", + "sdesc": "", + "source": "rpm" + }, + "btfs": { + "aid": "", + "sdesc": "", + "source": "rpm" + } +} + +print(ProgramSetup(Console(), app, "install").setup()) From ef3e907d786ea342ecf8cd9598c8a42e8337dd60 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 00:58:43 +0800 Subject: [PATCH 177/240] move scripts to scripts/ --- script1.sh => scripts/script1.sh | 0 script2.sh => scripts/script2.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename script1.sh => scripts/script1.sh (100%) rename script2.sh => scripts/script2.sh (100%) diff --git a/script1.sh b/scripts/script1.sh similarity index 100% rename from script1.sh rename to scripts/script1.sh diff --git a/script2.sh b/scripts/script2.sh similarity index 100% rename from script2.sh rename to scripts/script2.sh From abc7fa8599e24f1578e657ac1219a7742f4c6a56 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 00:59:46 +0800 Subject: [PATCH 178/240] prefix r_ to rpm applications --- src/utils/core/programs/add_remove.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 946647a..8ecb798 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -100,9 +100,9 @@ def setup(self) -> tuple[list[list[str]], list[str]]: t_fp_cmd: list[list[str]] = [] t_rpm_prog: dict[str, list[str]] = { - "m_repo": [], #* main repo - "rf_free": [], #* rpmfusion free - "rf_nfree": [] #* rpmfusion nonfree + "r_m_repo": [], #* main repo + "r_rf_free": [], #* rpmfusion free + "r_rf_nfree": [] #* rpmfusion nonfree } # fp_ind -> flatpak programs ind From e5e4739ab319b8f3c65763d07e13880ef2a86f39 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:03:04 +0800 Subject: [PATCH 179/240] suffix _ in parameters to avoid shadowing arguments of function --- src/utils/shared/misc/section.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/shared/misc/section.py b/src/utils/shared/misc/section.py index 83b47d3..8446d2b 100644 --- a/src/utils/shared/misc/section.py +++ b/src/utils/shared/misc/section.py @@ -4,7 +4,7 @@ from rich.text import Text -def section(msg: str, title: str) -> None: +def section(title_: str, msg_: str = None) -> None: """For displaying of title in major operation. Args: @@ -16,13 +16,13 @@ def section(msg: str, title: str) -> None: Panel( Align( Text( - msg.upper(), + msg_.upper(), justify="center" ), vertical="middle", align="center" ), - title=f"[bold]{title.upper()}[/bold]" + title=title_ ) ) From 32896ddf755f7b3425496ae4e749b096ff181d27 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:03:38 +0800 Subject: [PATCH 180/240] swap the value of title_ & msg_ if msg_ is none --- src/utils/shared/misc/section.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/shared/misc/section.py b/src/utils/shared/misc/section.py index 8446d2b..356dcdf 100644 --- a/src/utils/shared/misc/section.py +++ b/src/utils/shared/misc/section.py @@ -12,6 +12,9 @@ def section(title_: str, msg_: str = None) -> None: title -- title of the section """ + if not msg_: + msg_, title_ = title_, None + Console().print( Panel( Align( From 6e32e16db903bfedf3c075cea618647dafd5cf04 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:05:03 +0800 Subject: [PATCH 181/240] remove progtype parameter and update arguments of section() --- src/utils/core/programs/add_remove.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 8ecb798..b5cea34 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -62,8 +62,7 @@ def __init__( def _enum_prog( self, progindex: ProgIndex, - progdata: ProgData, - progtype: str + progdata: ProgData ) -> Any: """Enumerate the programs in the list and print out with a format. @@ -75,8 +74,7 @@ def _enum_prog( """ section( - f"{self.action}ion of recommended programs", - f"recommended programs ({progtype})" + f"{self.action}ion of recommended programs", None ) ind: int; progname: str From c566ee4f234b6821be8fac6e394860a4779ac24d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:06:09 +0800 Subject: [PATCH 182/240] type hint the 4 variables in dict comprehension --- src/utils/core/programs/add_remove.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index b5cea34..250542e 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -25,6 +25,8 @@ def __init__( self.console: Console = console + progname: str; aid: str; sdesc: str; source: str + self.fp_PROGARR: ProgData = { progname: { "aid": proginfo.get("aid"), From 436f2fc0bdefaf63d03ca1f83ea5ef02dc6bc3c0 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:28:13 +0800 Subject: [PATCH 183/240] update aid of rpm programs --- config/app_for_install.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 67859da..1e7ce48 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -100,87 +100,87 @@ "source": "flatpak" }, "exiftool": { - "aid": "", + "aid": "exiftool", "sdesc": "", "source": "rpm" }, "perl-Image-ExifTool": { - "aid": "", + "aid": "perl-Image-ExifTool", "sdesc": "", "source": "rpm" }, "clamtk*": { - "aid": "", + "aid": "clamtk*", "sdesc": "", "source": "rpm" }, "fail2ban": { - "aid": "", + "aid": "fail2ban", "sdesc": "", "source": "rpm" }, "tlp": { - "aid": "", + "aid": "tlp", "sdesc": "", "source": "rpm" }, "make": { - "aid": "", + "aid": "make", "sdesc": "", "source": "rpm" }, "gcc-c++": { - "aid": "", + "aid": "gcc-c++", "sdesc": "", "source": "rpm" }, "qemu-kvm": { - "aid": "", + "aid": "qemu-kvm", "sdesc": "", "source": "rpm" }, "qemu-img": { - "aid": "", + "aid": "qemu-img", "sdesc": "", "source": "rpm" }, "qemu-user-static": { - "aid": "", + "aid": "qemu-user-static", "sdesc": "", "source": "rpm" }, "ffmpegthumbs": { - "aid": "", + "aid": "ffmpegthumbs", "sdesc": "", "source": "rpm" }, "kffmpegthumbnailer": { - "aid": "", + "aid": "kffmpegthumbnailer", "sdesc": "", "source": "rpm" }, "unrar": { - "aid": "", + "aid": "unrar", "sdesc": "", "source": "rpm" }, "stacer": { - "aid": "", + "aid": "stacer", "sdesc": "", "source": "rpm" }, "python-pip": { - "aid": "", + "aid": "python-pip", "sdesc": "", "source": "rpm" }, "android-tools": { - "aid": "", + "aid": "android-tools", "sdesc": "", "source": "rpm" }, "btfs": { - "aid": "", + "aid": "btfs", "sdesc": "", "source": "rpm" } From 36495b65906bcff18dc846e10bd112b0cea33c69 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:28:35 +0800 Subject: [PATCH 184/240] replace source of flatpak applications to flathub --- config/app_for_install.json | 42 +++++++++++++-------------- src/utils/core/programs/add_remove.py | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 1e7ce48..2856b0e 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -2,102 +2,102 @@ "Mailspring": { "aid": "com.getmailspring.Mailspring", "sdesc": "A simple email client.", - "source": "flatpak" + "source": "flathub" }, "LibreOffice": { "aid": "org.libreoffice.LibreOffice", "sdesc": "Office suite.", - "source": "flatpak" + "source": "flathub" }, "VLC": { "aid": "org.videolan.VLC", "sdesc": "Video player.", - "source": "flatpak" + "source": "flathub" }, "Okular": { "aid": "org.kde.okular", "sdesc": "A document viewer.", - "source": "flatpak" + "source": "flathub" }, "GIMP": { "aid": "org.gimp.GIMP", "sdesc": "Photo editing application.", - "source": "flatpak" + "source": "flathub" }, "ClamTk": { "aid": "com.gitlab.davem.ClamTk", "sdesc": "Front end for ClamAV.", - "source": "flatpak" + "source": "flathub" }, "FlatSeal": { "aid": "com.github.tchx84.Flatseal", - "sdesc": "GUI for managing flatpak applications permission", - "source": "flatpak" + "sdesc": "GUI for managing flathub applications permission", + "source": "flathub" }, "KeepassXC": { "aid": "org.keepassxc.KeePassXC", "sdesc": "Secure Password manager.", - "source": "flatpak" + "source": "flathub" }, "Cryptomator": { "aid": "org.cryptomator.Cryptomator", "sdesc": "Secure and easy encryption, especially for Cloud storages.", - "source": "flatpak" + "source": "flathub" }, "Easy-Effects": { "aid": "com.github.wwmm.easyeffects", "sdesc": "Modify your PulseAudio sound", - "source": "flatpak" + "source": "flathub" }, "Sync-Thingy": { "aid": "com.github.zocker_160.SyncThingy", "sdesc": "Sync folders securely between devices, no server.", - "source": "flatpak" + "source": "flathub" }, "XNView MP": { "aid": "com.xnview.XnViewMP", "sdesc": "Image Viewer and editor with many functions", - "source": "flatpak" + "source": "flathub" }, "Freetube": { "aid": "io.freetubeapp.FreeTube", "sdesc": "Watch YouTube privately with local subscriptions and playlists.", - "source": "flatpak" + "source": "flathub" }, "Inkscape": { "aid": "org.inkscape.Inkscape", "sdesc": "A Vector graphics program", - "source": "flatpak" + "source": "flathub" }, "GNOME Boxen": { "aid": "org.gnome.Boxes", "sdesc": "Manage fast Virtual machines with a simple interface.", - "source": "flatpak" + "source": "flathub" }, "Filelight": { "aid": "org.kde.filelight ", "sdesc": "View what files consume how much space in a pie chart.", - "source": "flatpak" + "source": "flathub" }, "Kdenlive": { "aid": "org.kde.kdenlive", "sdesc": "Video cut program", - "source": "flatpak" + "source": "flathub" }, "Onion Share": { "aid": "org.onionshare.OnionShare", "sdesc": "Share files, chat and create websites over Tor", - "source": "flatpak" + "source": "flathub" }, "qBittorrent": { "aid": "org.qbittorrent.qBittorrent", "sdesc": "Share files decentral with a big community.", - "source": "flatpak" + "source": "flathub" }, "Metadata-cleaner": { "aid": "fr.romainvigier.MetadataCleaner", "sdesc": "Easily remove all identifying information on Images using exiftool.", - "source": "flatpak" + "source": "flathub" }, "exiftool": { "aid": "exiftool", diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 250542e..99f9c27 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -33,7 +33,7 @@ def __init__( "sdesc": proginfo.get("sdesc"), "source": proginfo.get("source") } for progname, proginfo in prog_data.items() - if proginfo.get("source").lower() == "flatpak" + if proginfo.get("source").lower() == "flathub" } self.rpm_PROGARR: ProgData = { progname: { From 954865545259f359ed9469c799a6e53b34dbef66 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:33:09 +0800 Subject: [PATCH 185/240] put back progtype and update section msg --- src/utils/core/programs/add_remove.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 99f9c27..304d234 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -64,7 +64,8 @@ def __init__( def _enum_prog( self, progindex: ProgIndex, - progdata: ProgData + progdata: ProgData, + progtype: str ) -> Any: """Enumerate the programs in the list and print out with a format. @@ -76,7 +77,7 @@ def _enum_prog( """ section( - f"{self.action}ion of recommended programs", None + f"select recommended programs ({progtype})", None ) ind: int; progname: str From 6f47462463601154188485d13cd974398c5a14a9 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:33:35 +0800 Subject: [PATCH 186/240] sort rpm applications based on the repository --- src/utils/core/programs/add_remove.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index 304d234..bebe56c 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -144,9 +144,19 @@ def setup(self) -> tuple[list[list[str]], list[str]]: for rpm_ind in self._enum_prog( self.rpm_PROGIND, self.rpm_PROGARR, "rpm" ): - r_aid: str = self.rpm_PROGARR.get( # type: ignore - self.rpm_PROGIND.get(rpm_ind) # type: ignore + + r_aid: str = self.rpm_PROGARR.get( + self.rpm_PROGIND.get(rpm_ind) ).get("aid") - t_rpm_prog.append(r_aid) + + match self.rpm_PROGARR.get( + self.rpm_PROGIND.get(rpm_ind) + ).get("source").lower(): + case "r_m_repo": + t_rpm_prog["r_m_repo"].append(r_aid) + case "r_rf_free": + t_rpm_prog["r_rf_free"].append(r_aid) + case "r_rf_nfree": + t_rpm_prog["r_rf_nfree"].append(r_aid) return t_fp_cmd, t_rpm_prog From 5519a3e382b31355cf2bccba44e06e1dc51a7aec Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:34:30 +0800 Subject: [PATCH 187/240] update test block for src.utils.core.programs.app_remove --- assets/test_block-app_remove | 77 ++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/assets/test_block-app_remove b/assets/test_block-app_remove index 684f53d..08b9eab 100644 --- a/assets/test_block-app_remove +++ b/assets/test_block-app_remove @@ -3,188 +3,189 @@ app = { "Mailspring": { "aid": "com.getmailspring.Mailspring", "sdesc": "A simple email client.", - "source": "flatpak" + "source": "flathub" }, "LibreOffice": { "aid": "org.libreoffice.LibreOffice", "sdesc": "Office suite.", - "source": "flatpak" + "source": "flathub" }, "VLC": { "aid": "org.videolan.VLC", "sdesc": "Video player.", - "source": "flatpak" + "source": "flathub" }, "Okular": { "aid": "org.kde.okular", "sdesc": "A document viewer.", - "source": "flatpak" + "source": "flathub" }, "GIMP": { "aid": "org.gimp.GIMP", "sdesc": "Photo editing application.", - "source": "flatpak" + "source": "flathub" }, "ClamTk": { "aid": "com.gitlab.davem.ClamTk", "sdesc": "Front end for ClamAV.", - "source": "flatpak" + "source": "flathub" }, "FlatSeal": { "aid": "com.github.tchx84.Flatseal", - "sdesc": "GUI for managing flatpak applications permission", - "source": "flatpak" + "sdesc": "GUI for managing flathub applications permission", + "source": "flathub" }, "KeepassXC": { "aid": "org.keepassxc.KeePassXC", "sdesc": "Secure Password manager.", - "source": "flatpak" + "source": "flathub" }, "Cryptomator": { "aid": "org.cryptomator.Cryptomator", "sdesc": "Secure and easy encryption, especially for Cloud storages.", - "source": "flatpak" + "source": "flathub" }, "Easy-Effects": { "aid": "com.github.wwmm.easyeffects", "sdesc": "Modify your PulseAudio sound", - "source": "flatpak" + "source": "flathub" }, "Sync-Thingy": { "aid": "com.github.zocker_160.SyncThingy", "sdesc": "Sync folders securely between devices, no server.", - "source": "flatpak" + "source": "flathub" }, "XNView MP": { "aid": "com.xnview.XnViewMP", "sdesc": "Image Viewer and editor with many functions", - "source": "flatpak" + "source": "flathub" }, "Freetube": { "aid": "io.freetubeapp.FreeTube", "sdesc": "Watch YouTube privately with local subscriptions and playlists.", - "source": "flatpak" + "source": "flathub" }, "Inkscape": { "aid": "org.inkscape.Inkscape", "sdesc": "A Vector graphics program", - "source": "flatpak" + "source": "flathub" }, "GNOME Boxen": { "aid": "org.gnome.Boxes", "sdesc": "Manage fast Virtual machines with a simple interface.", - "source": "flatpak" + "source": "flathub" }, "Filelight": { "aid": "org.kde.filelight ", "sdesc": "View what files consume how much space in a pie chart.", - "source": "flatpak" + "source": "flathub" }, "Kdenlive": { "aid": "org.kde.kdenlive", "sdesc": "Video cut program", - "source": "flatpak" + "source": "flathub" }, "Onion Share": { "aid": "org.onionshare.OnionShare", "sdesc": "Share files, chat and create websites over Tor", - "source": "flatpak" + "source": "flathub" }, "qBittorrent": { "aid": "org.qbittorrent.qBittorrent", "sdesc": "Share files decentral with a big community.", - "source": "flatpak" + "source": "flathub" }, "Metadata-cleaner": { "aid": "fr.romainvigier.MetadataCleaner", "sdesc": "Easily remove all identifying information on Images using exiftool.", - "source": "flatpak" + "source": "flathub" }, "exiftool": { - "aid": "", + "aid": "exiftool", "sdesc": "", "source": "rpm" }, "perl-Image-ExifTool": { - "aid": "", + "aid": "perl-Image-ExifTool", "sdesc": "", "source": "rpm" }, "clamtk*": { - "aid": "", + "aid": "clamtk*", "sdesc": "", "source": "rpm" }, "fail2ban": { - "aid": "", + "aid": "fail2ban", "sdesc": "", "source": "rpm" }, "tlp": { - "aid": "", + "aid": "tlp", "sdesc": "", "source": "rpm" }, "make": { - "aid": "", + "aid": "make", "sdesc": "", "source": "rpm" }, "gcc-c++": { - "aid": "", + "aid": "gcc-c++", "sdesc": "", "source": "rpm" }, "qemu-kvm": { - "aid": "", + "aid": "qemu-kvm", "sdesc": "", "source": "rpm" }, "qemu-img": { - "aid": "", + "aid": "qemu-img", "sdesc": "", "source": "rpm" }, "qemu-user-static": { - "aid": "", + "aid": "qemu-user-static", "sdesc": "", "source": "rpm" }, "ffmpegthumbs": { - "aid": "", + "aid": "ffmpegthumbs", "sdesc": "", "source": "rpm" }, "kffmpegthumbnailer": { - "aid": "", + "aid": "kffmpegthumbnailer", "sdesc": "", "source": "rpm" }, "unrar": { - "aid": "", + "aid": "unrar", "sdesc": "", "source": "rpm" }, "stacer": { - "aid": "", + "aid": "stacer", "sdesc": "", "source": "rpm" }, "python-pip": { - "aid": "", + "aid": "python-pip", "sdesc": "", "source": "rpm" }, "android-tools": { - "aid": "", + "aid": "android-tools", "sdesc": "", "source": "rpm" }, "btfs": { - "aid": "", + "aid": "btfs", "sdesc": "", "source": "rpm" } } + print(ProgramSetup(Console(), app, "install").setup()) From 5754cdd0b4210a68387e7de6f2d03949f6d75076 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:49:22 +0800 Subject: [PATCH 188/240] update type hints --- src/misc/alias.py | 2 +- src/utils/conf/fetch_config.py | 4 +-- src/utils/core/programs/add_remove.py | 28 +++++++++---------- src/utils/core/programs/tp_repo_install.py | 2 +- .../core/system/optimizations/sys_opt.py | 6 ++-- src/utils/shared/fetch_env.py | 10 +++---- src/utils/shared/log/logger.py | 2 +- src/utils/shared/misc/section.py | 14 ++++++---- src/utils/shared/misc/uinput.py | 2 +- 9 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/misc/alias.py b/src/misc/alias.py index c40238c..b170044 100644 --- a/src/misc/alias.py +++ b/src/misc/alias.py @@ -1,4 +1,4 @@ -ProgData = dict[str, dict[str, str, str]] +ProgData = dict[str, dict[str, str]] ProgIndex = dict[int, str] ConfigValues = list[ list[dict[str, str | dict[str, str]]] | dict[str, str] diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 9844b3e..1d6a8d3 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -1,4 +1,4 @@ -from typing import NoReturn +from typing import NoReturn, Optional from requests import get @@ -9,7 +9,7 @@ def fetch_missing_config( log: Logger, conf_name: str, CONF_PATH: str, - conf_links: dict[str, str] = None + conf_links: Optional[dict[str, str]] = None ) -> None | NoReturn: """Downloads the original config file from github if not found. diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index bebe56c..f55ac87 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -1,6 +1,6 @@ from typing import Any -from rich.console import Console +from rich.console import Console # type: ignore from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.section import section @@ -29,19 +29,19 @@ def __init__( self.fp_PROGARR: ProgData = { progname: { - "aid": proginfo.get("aid"), - "sdesc": proginfo.get("sdesc"), - "source": proginfo.get("source") + "aid": proginfo.get("aid"), # type: ignore + "sdesc": proginfo.get("sdesc"), # type: ignore + "source": proginfo.get("source") # type: ignore } for progname, proginfo in prog_data.items() - if proginfo.get("source").lower() == "flathub" + if proginfo.get("source").lower() == "flathub" # type: ignore } self.rpm_PROGARR: ProgData = { progname: { - "aid": proginfo.get("aid"), - "sdesc": proginfo.get("sdesc"), - "source": proginfo.get("source") + "aid": proginfo.get("aid"), # type: ignore + "sdesc": proginfo.get("sdesc"), # type: ignore + "source": proginfo.get("source") # type: ignore } for progname, proginfo in prog_data.items() - if proginfo.get("source").lower() in [ + if proginfo.get("source").lower() in [ # type: ignore "rpm", "rfusion_free", "rfusion_nfree" ] } @@ -96,7 +96,7 @@ def _enum_prog( 2 ) - def setup(self) -> tuple[list[list[str]], list[str]]: + def setup(self) -> tuple[list[list[str]], dict[str, list[str]]]: """For add/remove of recommended program selected by user.""" t_fp_cmd: list[list[str]] = [] @@ -145,12 +145,12 @@ def setup(self) -> tuple[list[list[str]], list[str]]: self.rpm_PROGIND, self.rpm_PROGARR, "rpm" ): - r_aid: str = self.rpm_PROGARR.get( - self.rpm_PROGIND.get(rpm_ind) + r_aid: str = self.rpm_PROGARR.get( # type: ignore + self.rpm_PROGIND.get(rpm_ind) # type: ignore ).get("aid") - match self.rpm_PROGARR.get( - self.rpm_PROGIND.get(rpm_ind) + match self.rpm_PROGARR.get( # type: ignore + self.rpm_PROGIND.get(rpm_ind) # type: ignore ).get("source").lower(): case "r_m_repo": t_rpm_prog["r_m_repo"].append(r_aid) diff --git a/src/utils/core/programs/tp_repo_install.py b/src/utils/core/programs/tp_repo_install.py index 0417a92..c6319c1 100644 --- a/src/utils/core/programs/tp_repo_install.py +++ b/src/utils/core/programs/tp_repo_install.py @@ -1,4 +1,4 @@ -from rich.console import Console +from rich.console import Console # type: ignore from src.utils.shared.misc.uinput import uinput diff --git a/src/utils/core/system/optimizations/sys_opt.py b/src/utils/core/system/optimizations/sys_opt.py index 7651910..079967f 100644 --- a/src/utils/core/system/optimizations/sys_opt.py +++ b/src/utils/core/system/optimizations/sys_opt.py @@ -1,4 +1,4 @@ -from rich.console import Console +from rich.console import Console # type: ignore from src.utils.shared.exec import exec_cmd from src.utils.shared.fetch_env import fetch_env @@ -36,7 +36,7 @@ def disable_services(self) -> None: ], ] - cmd: str + cmd: str | list[str] for cmd in cmd_arr: if uinput(self.console, f"Execute: {cmd}", 1): exec_cmd(self.log, cmd, self.verbose) @@ -63,6 +63,6 @@ def de_based_opt(self) -> None: if uinput(self.console, f"Execute: {cmd}", 1): exec_cmd(self.log, cmd, self.verbose) - def disable_workqueue(self): + def disable_workqueue(self) -> None: """Disable workqueue to improve ssd performance""" ... diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py index e9d7275..651c520 100755 --- a/src/utils/shared/fetch_env.py +++ b/src/utils/shared/fetch_env.py @@ -1,13 +1,13 @@ from os import getenv from typing import Optional -from rich.console import Console +from rich.console import Console # type: ignore from src.utils.shared.misc.uinput import uinput from src.utils.shared.log.logger import Logger -def fetch_env(log: Logger, console: Console, env_var: str) -> Optional[str]: +def fetch_env(log: Logger, console: Console, env_var: str) -> str: """Fetch the value of given env variable. Args: @@ -15,15 +15,15 @@ def fetch_env(log: Logger, console: Console, env_var: str) -> Optional[str]: env_var -- variable to fetch Returns: - The value of env variable or None + The value of env variable """ try: env_val: Optional[str] = getenv(env_var.upper()) except OSError as Err: log.logger("e", f"{Err}. No value found for {env_var}.") - env_val = uinput( + env_val_u = uinput( console, f"Kindly input the value for {env_var}", 3 ) - return env_val + return env_val or env_val_u diff --git a/src/utils/shared/log/logger.py b/src/utils/shared/log/logger.py index 25cf90c..97de8da 100755 --- a/src/utils/shared/log/logger.py +++ b/src/utils/shared/log/logger.py @@ -3,7 +3,7 @@ from os import mkdir from os.path import exists -from rich.logging import RichHandler +from rich.logging import RichHandler # type: ignore class Logger: diff --git a/src/utils/shared/misc/section.py b/src/utils/shared/misc/section.py index 356dcdf..43da572 100644 --- a/src/utils/shared/misc/section.py +++ b/src/utils/shared/misc/section.py @@ -1,10 +1,12 @@ -from rich.console import Console -from rich.panel import Panel -from rich.align import Align -from rich.text import Text +from typing import Optional +from rich.console import Console # type: ignore +from rich.panel import Panel # type: ignore +from rich.align import Align # type: ignore +from rich.text import Text # type: ignore -def section(title_: str, msg_: str = None) -> None: + +def section(title_: str, msg_: Optional[str] = None) -> None: """For displaying of title in major operation. Args: @@ -13,7 +15,7 @@ def section(title_: str, msg_: str = None) -> None: """ if not msg_: - msg_, title_ = title_, None + msg_, title_ = title_, None # type: ignore Console().print( Panel( diff --git a/src/utils/shared/misc/uinput.py b/src/utils/shared/misc/uinput.py index 286b908..cdf9f61 100755 --- a/src/utils/shared/misc/uinput.py +++ b/src/utils/shared/misc/uinput.py @@ -1,6 +1,6 @@ from typing import Any -from rich.console import Console +from rich.console import Console # type: ignore def uinput(console: Console, msg: str, qtype: int) -> Any: From 65cf2e2f87180d6e5e8c61ec0c9c7c97117f0750 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 25 Jan 2023 01:54:38 +0800 Subject: [PATCH 189/240] remove unused type: ignore --- src/utils/core/programs/add_remove.py | 2 +- src/utils/core/programs/tp_repo_install.py | 2 +- src/utils/core/system/optimizations/sys_opt.py | 2 +- src/utils/shared/fetch_env.py | 2 +- src/utils/shared/log/logger.py | 2 +- src/utils/shared/misc/section.py | 8 ++++---- src/utils/shared/misc/uinput.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/add_remove.py index f55ac87..6436b08 100644 --- a/src/utils/core/programs/add_remove.py +++ b/src/utils/core/programs/add_remove.py @@ -1,6 +1,6 @@ from typing import Any -from rich.console import Console # type: ignore +from rich.console import Console from src.utils.shared.misc.uinput import uinput from src.utils.shared.misc.section import section diff --git a/src/utils/core/programs/tp_repo_install.py b/src/utils/core/programs/tp_repo_install.py index c6319c1..0417a92 100644 --- a/src/utils/core/programs/tp_repo_install.py +++ b/src/utils/core/programs/tp_repo_install.py @@ -1,4 +1,4 @@ -from rich.console import Console # type: ignore +from rich.console import Console from src.utils.shared.misc.uinput import uinput diff --git a/src/utils/core/system/optimizations/sys_opt.py b/src/utils/core/system/optimizations/sys_opt.py index 079967f..8886187 100644 --- a/src/utils/core/system/optimizations/sys_opt.py +++ b/src/utils/core/system/optimizations/sys_opt.py @@ -1,4 +1,4 @@ -from rich.console import Console # type: ignore +from rich.console import Console from src.utils.shared.exec import exec_cmd from src.utils.shared.fetch_env import fetch_env diff --git a/src/utils/shared/fetch_env.py b/src/utils/shared/fetch_env.py index 651c520..9903651 100755 --- a/src/utils/shared/fetch_env.py +++ b/src/utils/shared/fetch_env.py @@ -1,7 +1,7 @@ from os import getenv from typing import Optional -from rich.console import Console # type: ignore +from rich.console import Console from src.utils.shared.misc.uinput import uinput from src.utils.shared.log.logger import Logger diff --git a/src/utils/shared/log/logger.py b/src/utils/shared/log/logger.py index 97de8da..25cf90c 100755 --- a/src/utils/shared/log/logger.py +++ b/src/utils/shared/log/logger.py @@ -3,7 +3,7 @@ from os import mkdir from os.path import exists -from rich.logging import RichHandler # type: ignore +from rich.logging import RichHandler class Logger: diff --git a/src/utils/shared/misc/section.py b/src/utils/shared/misc/section.py index 43da572..0d4341f 100644 --- a/src/utils/shared/misc/section.py +++ b/src/utils/shared/misc/section.py @@ -1,9 +1,9 @@ from typing import Optional -from rich.console import Console # type: ignore -from rich.panel import Panel # type: ignore -from rich.align import Align # type: ignore -from rich.text import Text # type: ignore +from rich.console import Console +from rich.panel import Panel +from rich.align import Align +from rich.text import Text def section(title_: str, msg_: Optional[str] = None) -> None: diff --git a/src/utils/shared/misc/uinput.py b/src/utils/shared/misc/uinput.py index cdf9f61..286b908 100755 --- a/src/utils/shared/misc/uinput.py +++ b/src/utils/shared/misc/uinput.py @@ -1,6 +1,6 @@ from typing import Any -from rich.console import Console # type: ignore +from rich.console import Console def uinput(console: Console, msg: str, qtype: int) -> Any: From 4d1d73ac044e2fb6c6eade3b3efb481998de2b4b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:20:21 +0800 Subject: [PATCH 190/240] rename to general_opt to be more specific --- .../core/system/optimizations/{sys_opt.py => general_opt.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/utils/core/system/optimizations/{sys_opt.py => general_opt.py} (100%) diff --git a/src/utils/core/system/optimizations/sys_opt.py b/src/utils/core/system/optimizations/general_opt.py similarity index 100% rename from src/utils/core/system/optimizations/sys_opt.py rename to src/utils/core/system/optimizations/general_opt.py From 7551deaf1ba85e828c2573010b7625a6a8e51158 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:21:10 +0800 Subject: [PATCH 191/240] for optimizations that depends on each variant of atomic workstation --- src/utils/core/system/optimizations/variant_based_opt.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/system/optimizations/variant_based_opt.py diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py new file mode 100644 index 0000000..e69de29 From 7758475e265ee3dffbb9e00574e2b4ac106b8601 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:36:00 +0800 Subject: [PATCH 192/240] lowercare the user input in mode 3 --- src/utils/shared/misc/uinput.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/shared/misc/uinput.py b/src/utils/shared/misc/uinput.py index 286b908..7d958b9 100755 --- a/src/utils/shared/misc/uinput.py +++ b/src/utils/shared/misc/uinput.py @@ -44,6 +44,6 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: ", separate by comma ','][/bold]" ), end=" " ) - return input().strip() + return input().strip().lower() return False From cc0c1bb335980c7a7cdaea0a3f32a7eab51ae546 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:36:31 +0800 Subject: [PATCH 193/240] _fetch_variant method for variant based optimizations --- .../system/optimizations/variant_based_opt.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index e69de29..a6e1c18 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -0,0 +1,38 @@ +from typing import Any, IO + +from rich.console import Console + +from src.utils.shared.misc.uinput import uinput +from src.utils.shared.log.logger import Logger + + +class VariantBasedOpt: + """Optimizations for specific variant of Fedora OSTree.""" + + def __init__(self, log: Logger, console: Console) -> None: + self.log: Logger = log + self.console: Console = console + + def _fetch_variant(self) -> str: + """Fetch the name of variant using /etc/os-release + + Returns: + The VARIANT_ID or VARIANT declared in /etc/os-release + """ + + try: + osr: IO[Any]; lines: str + with open("/etc/os-release", "r", encoding="UTF-8") as osr: + for lines in osr.readlines(): + if lines.lower().startswith("variant_id"): + return lines.removeprefix("variant_id") + elif lines.lower().startswith("variant"): + return lines.removeprefix("variant") + except (FileNotFoundError, PermissionError) as Err: + self.log.logger("E", "Cannot find /etc/os-release file.") + + return uinput( + self.console, + "Kindly input the Fedora OSTree variant you are using", + 3 + ) From fb5e286f26b7c86b9a06915935d4c1816e6e9365 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:40:38 +0800 Subject: [PATCH 194/240] merge two conditions and chain call the methods passed --- .../core/system/optimizations/variant_based_opt.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index a6e1c18..c36031b 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -24,12 +24,15 @@ def _fetch_variant(self) -> str: osr: IO[Any]; lines: str with open("/etc/os-release", "r", encoding="UTF-8") as osr: for lines in osr.readlines(): - if lines.lower().startswith("variant_id"): - return lines.removeprefix("variant_id") - elif lines.lower().startswith("variant"): - return lines.removeprefix("variant") + if lines.lower().startswith(("variant_id", "variant")): + return ( + lines + .removeprefix("variant_id") + .removeprefix("variant") + .replace(r"\n", "") + ) except (FileNotFoundError, PermissionError) as Err: - self.log.logger("E", "Cannot find /etc/os-release file.") + self.log.logger("E", f"{Err}. Cannot find /etc/os-release file.") return uinput( self.console, From 10c428ce76b7aa3e38a49c28464c2c88286fed20 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:42:55 +0800 Subject: [PATCH 195/240] include .replace() method to remove accidental entry of new line --- src/utils/shared/misc/uinput.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/shared/misc/uinput.py b/src/utils/shared/misc/uinput.py index 7d958b9..0974a92 100755 --- a/src/utils/shared/misc/uinput.py +++ b/src/utils/shared/misc/uinput.py @@ -44,6 +44,6 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: ", separate by comma ','][/bold]" ), end=" " ) - return input().strip().lower() + return input().strip().lower().replace(r"\n", "") return False From f6fd64fe43ce2a83bd664659db93037d7a08f0e8 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:46:23 +0800 Subject: [PATCH 196/240] initial commit on variants --- .../core/system/optimizations/variant_based_opt.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index c36031b..e09968c 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -1,4 +1,4 @@ -from typing import Any, IO +from typing import Any, IO, NoReturn from rich.console import Console @@ -39,3 +39,13 @@ def _fetch_variant(self) -> str: "Kindly input the Fedora OSTree variant you are using", 3 ) + + def remove_base_programs(self) -> NoReturn | None: + """Remova programs layered in base image of a given variant.""" + + variant: str = self._fetch_variant() + + match variant: + case "kinoite": ... + case "silverblue": ... + case "vauxite": ... #! from what ive heard this variant is still not yet official From fd04021fef7741663a65ff5317e1c781a227318f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:48:39 +0800 Subject: [PATCH 197/240] take variant as parameter --- src/utils/core/system/optimizations/variant_based_opt.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index e09968c..b2c65dc 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -40,11 +40,9 @@ def _fetch_variant(self) -> str: 3 ) - def remove_base_programs(self) -> NoReturn | None: + def remove_base_programs(self, variant: str) -> NoReturn | None: """Remova programs layered in base image of a given variant.""" - variant: str = self._fetch_variant() - match variant: case "kinoite": ... case "silverblue": ... From a6c4e5c2638ad89a3669f6632e7e147bd56a74be Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:50:25 +0800 Subject: [PATCH 198/240] use dictionary instead of repetitive pattern matching over the methods --- .../core/system/optimizations/variant_based_opt.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index b2c65dc..4a4b408 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -41,9 +41,10 @@ def _fetch_variant(self) -> str: ) def remove_base_programs(self, variant: str) -> NoReturn | None: - """Remova programs layered in base image of a given variant.""" + """Remove programs layered in base image of a given variant.""" - match variant: - case "kinoite": ... - case "silverblue": ... - case "vauxite": ... #! from what ive heard this variant is still not yet official + base_programs: dict[str, list[str]] = { + "kinoite": [], + "silverblue": [], + "vauxite": [] #! from what ive heard this variant is still not yet official + } From a2c6d7d9b1f0b17870fa8b2a42278ccca3c9eb1a Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:52:59 +0800 Subject: [PATCH 199/240] system optimization for silverblue variant --- .../system/optimizations/variant_based_opt.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index 4a4b408..2d71b6a 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -48,3 +48,20 @@ def remove_base_programs(self, variant: str) -> NoReturn | None: "silverblue": [], "vauxite": [] #! from what ive heard this variant is still not yet official } + + + def sys_opt(self, variant: str) -> NoReturn | None: + """Removal/alteration of default settings that are + known to be detrimental in terms of performance.""" + + sys_opts: dict[str, list[str]] = { + "kinoite": [], + "silverblue": [ + [ # disable gnome software from autostart + "sudo", + "rm", + "/etc/xdg/autostart/org.gnome.Software.desktop" + ] + ], + "vauxite": [] + } From 6bf9899d0c9ce1e4c58bb46cce6a77d29b028aac Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 21:53:32 +0800 Subject: [PATCH 200/240] remove de_based_opt... method --- .../core/system/optimizations/general_opt.py | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/src/utils/core/system/optimizations/general_opt.py b/src/utils/core/system/optimizations/general_opt.py index 8886187..31d5ed4 100644 --- a/src/utils/core/system/optimizations/general_opt.py +++ b/src/utils/core/system/optimizations/general_opt.py @@ -41,28 +41,6 @@ def disable_services(self) -> None: if uinput(self.console, f"Execute: {cmd}", 1): exec_cmd(self.log, cmd, self.verbose) - def de_based_opt(self) -> None: - """For disabling of autostart exclusive on specific de""" - match fetch_env( - self.log, self.console, "XDG_SESSION_DESKTOP" - ).lower(): - case "gnome": - cmd_arr: list[list[str]] = [ - [ - "sudo", - "rm", - "/etc/xdg/autostart/org.gnome.Software.desktop" - ] - ] - case "kde": - ... # disable baloo - case _: - return None - - for cmd in cmd_arr: - if uinput(self.console, f"Execute: {cmd}", 1): - exec_cmd(self.log, cmd, self.verbose) - def disable_workqueue(self) -> None: """Disable workqueue to improve ssd performance""" ... From 4872516727f285efcec0959b98be71334454a39e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 28 Jan 2023 22:00:09 +0800 Subject: [PATCH 201/240] include psutil==5.9.4 --- REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) diff --git a/REQUIREMENTS b/REQUIREMENTS index 2e6e91f..0751eb3 100755 --- a/REQUIREMENTS +++ b/REQUIREMENTS @@ -1,2 +1,3 @@ rich==12.6.0 requests==2.28.1 +psutil==5.9.4 From 5af2d66108057f8f215971a64849f2b7e51d1614 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 20:54:41 +0800 Subject: [PATCH 202/240] initial commit on determining whether a partition is encrypted --- src/utils/core/system/optimizations/variant_based_opt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index 2d71b6a..3c21dd9 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -49,7 +49,6 @@ def remove_base_programs(self, variant: str) -> NoReturn | None: "vauxite": [] #! from what ive heard this variant is still not yet official } - def sys_opt(self, variant: str) -> NoReturn | None: """Removal/alteration of default settings that are known to be detrimental in terms of performance.""" From 654ed229ed58080afbaa814aab858d128973c89e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 20:57:00 +0800 Subject: [PATCH 203/240] initial commit on determining whether a partition is encrypted --- src/utils/core/system/optimizations/general_opt.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/core/system/optimizations/general_opt.py b/src/utils/core/system/optimizations/general_opt.py index 31d5ed4..bdc55a5 100644 --- a/src/utils/core/system/optimizations/general_opt.py +++ b/src/utils/core/system/optimizations/general_opt.py @@ -1,4 +1,7 @@ +from typing import Any + from rich.console import Console +from psutil import disk_partitions from src.utils.shared.exec import exec_cmd from src.utils.shared.fetch_env import fetch_env @@ -43,4 +46,10 @@ def disable_services(self) -> None: def disable_workqueue(self) -> None: """Disable workqueue to improve ssd performance""" - ... + + disk_names: list[str] = [ + parts.device for parts in disk_partitions() + ] + + for disks in disk_names: ... + From 6c51f5888e3e0f540f4d0a06ac685fdd3985de8b Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:00:38 +0800 Subject: [PATCH 204/240] initial commit on laptop improvements (#17) --- src/utils/core/system/laptop/__init__.py | 0 src/utils/core/system/laptop/battery_thresh.py | 0 src/utils/core/system/laptop/kbd_backlight.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/utils/core/system/laptop/__init__.py create mode 100644 src/utils/core/system/laptop/battery_thresh.py create mode 100644 src/utils/core/system/laptop/kbd_backlight.py diff --git a/src/utils/core/system/laptop/__init__.py b/src/utils/core/system/laptop/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/core/system/laptop/battery_thresh.py b/src/utils/core/system/laptop/battery_thresh.py new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/core/system/laptop/kbd_backlight.py b/src/utils/core/system/laptop/kbd_backlight.py new file mode 100644 index 0000000..e69de29 From ae7239bd84dbb4f62f8dbf5db740aee2d6a1d907 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:18:06 +0800 Subject: [PATCH 205/240] include support for pipe in commands --- src/utils/shared/exec.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index 1f6c358..ba7d4ce 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -1,6 +1,6 @@ from shutil import which -from subprocess import run, CalledProcessError, DEVNULL -from typing import NoReturn +from subprocess import run, CalledProcessError, DEVNULL, Popen, PIPE, check_output +from typing import NoReturn, Optional from src.utils.shared.log.logger import Logger @@ -9,7 +9,9 @@ def exec_cmd( log: Logger, command: list[str], verbose: bool = False, - break_proc: bool = False + break_proc: bool = False, + pipe_: bool = False, + init_cmd: Optional[list[str]] = None ) -> NoReturn | None: """For command execution/system calls with error handling @@ -30,6 +32,17 @@ def exec_cmd( ) raise SystemExit + if pipe_: + init_cmd_out = Popen(init_cmd, stdout=PIPE) + pipe_cmd: bytes = check_output( + command, stdin=init_cmd_out.stdout + ) + init_cmd_out.wait() + + if init_cmd_out.returncode != 0: + CalledProcessError(init_cmd_out.returncode, init_cmd) + + return pipe_cmd.decode("utf-8").strip().replace(r"\n", "") if verbose: ret: int = run(command).returncode else: From a9d15178005df59ca8666f08b19e7058ed2137b2 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:18:56 +0800 Subject: [PATCH 206/240] include pipe_ and init_cmd to docstring --- src/utils/shared/exec.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index ba7d4ce..c2f1979 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -20,6 +20,8 @@ def exec_cmd( command -- command to execute with arguments verbose -- whether to show command output or not break_proc -- whether to raise systemexit or not + pipe_ -- whether to pipe a command or not + init_cmd -- initial command to be piped to the main command Returns: None or raise system exit From 349701f281490a2a1acd2edc183fa4eae887b7ff Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:19:23 +0800 Subject: [PATCH 207/240] update docstring --- src/utils/shared/exec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index c2f1979..597a357 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -24,7 +24,7 @@ def exec_cmd( init_cmd -- initial command to be piped to the main command Returns: - None or raise system exit + None, the output of the command or raise system exit """ try: From 66afe0ac755f39bf43016a1cacf6069965f1fad5 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:20:25 +0800 Subject: [PATCH 208/240] rename parameter command to cmd --- src/utils/shared/exec.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index 597a357..e3bec1a 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -7,7 +7,7 @@ def exec_cmd( log: Logger, - command: list[str], + cmd: list[str], verbose: bool = False, break_proc: bool = False, pipe_: bool = False, @@ -17,7 +17,7 @@ def exec_cmd( Args: log -- Logger instance - command -- command to execute with arguments + cmd -- command to execute with arguments verbose -- whether to show command output or not break_proc -- whether to raise systemexit or not pipe_ -- whether to pipe a command or not @@ -28,16 +28,16 @@ def exec_cmd( """ try: - if which(command[0]) is None: + if which(cmd[0]) is None: log.logger( - "E", f"Program: {command[0]} does not exists, aborting ..." + "E", f"Program: {cmd[0]} does not exists, aborting ..." ) raise SystemExit if pipe_: init_cmd_out = Popen(init_cmd, stdout=PIPE) pipe_cmd: bytes = check_output( - command, stdin=init_cmd_out.stdout + cmd, stdin=init_cmd_out.stdout ) init_cmd_out.wait() @@ -46,20 +46,20 @@ def exec_cmd( return pipe_cmd.decode("utf-8").strip().replace(r"\n", "") if verbose: - ret: int = run(command).returncode + ret: int = run(cmd).returncode else: - ret = run(command, stdout=DEVNULL).returncode + ret = run(cmd, stdout=DEVNULL).returncode if ret != 0: - raise CalledProcessError(ret, command) + raise CalledProcessError(ret, cmd) else: - log.logger("I", f"Successfully executed the command: {command}") + log.logger("I", f"Successfully executed the command: {cmd}") except (OSError, CalledProcessError) as Err: log.logger( "E", ( f"{Err} encountered, cannot execute" - " command: {command} ..." + " command: {cmd} ..." ) ) From 355c3e7afe430990349c985208b95f5204e42d56 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:21:32 +0800 Subject: [PATCH 209/240] remove extra and unnecessary else statement --- src/utils/shared/exec.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index e3bec1a..a2bd392 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -45,6 +45,7 @@ def exec_cmd( CalledProcessError(init_cmd_out.returncode, init_cmd) return pipe_cmd.decode("utf-8").strip().replace(r"\n", "") + if verbose: ret: int = run(cmd).returncode else: @@ -52,8 +53,8 @@ def exec_cmd( if ret != 0: raise CalledProcessError(ret, cmd) - else: - log.logger("I", f"Successfully executed the command: {cmd}") + + log.logger("I", f"Successfully executed the command: {cmd}") except (OSError, CalledProcessError) as Err: log.logger( "E", From c54fe5afe898e856d7ac21c811e639876dc46087 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:24:21 +0800 Subject: [PATCH 210/240] fix lines exceeding 79 lines, update type hint and simplify syntax --- src/utils/shared/exec.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index a2bd392..0a2e8e2 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -1,5 +1,12 @@ from shutil import which -from subprocess import run, CalledProcessError, DEVNULL, Popen, PIPE, check_output +from subprocess import ( + run, + CalledProcessError, + DEVNULL, + Popen, + PIPE, + check_output +) from typing import NoReturn, Optional from src.utils.shared.log.logger import Logger @@ -12,7 +19,7 @@ def exec_cmd( break_proc: bool = False, pipe_: bool = False, init_cmd: Optional[list[str]] = None - ) -> NoReturn | None: + ) -> NoReturn | None | str: """For command execution/system calls with error handling Args: @@ -28,7 +35,7 @@ def exec_cmd( """ try: - if which(cmd[0]) is None: + if not which(cmd[0]): log.logger( "E", f"Program: {cmd[0]} does not exists, aborting ..." ) @@ -42,10 +49,17 @@ def exec_cmd( init_cmd_out.wait() if init_cmd_out.returncode != 0: - CalledProcessError(init_cmd_out.returncode, init_cmd) + raise CalledProcessError( + init_cmd_out.returncode, init_cmd + ) + + return ( + pipe_cmd + .decode("utf-8") + .strip() + .replace(r"\n", "") + ) - return pipe_cmd.decode("utf-8").strip().replace(r"\n", "") - if verbose: ret: int = run(cmd).returncode else: From 41e7d8ecb22a2c2731bae2d5be3282090f370609 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:29:33 +0800 Subject: [PATCH 211/240] implement exec.exec_cmd pipe feature and replace manual piping --- src/utils/core/drv_codecs/gpu_install.py | 28 +++++++++--------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/utils/core/drv_codecs/gpu_install.py b/src/utils/core/drv_codecs/gpu_install.py index a975663..0f56bd1 100644 --- a/src/utils/core/drv_codecs/gpu_install.py +++ b/src/utils/core/drv_codecs/gpu_install.py @@ -1,11 +1,7 @@ -from subprocess import ( - Popen, - CalledProcessError, - PIPE, - check_output -) +from subprocess import CalledProcessError from typing import Optional +from src.utils.shared.exec import exec_cmd from src.utils.shared.log.logger import Logger @@ -25,25 +21,21 @@ def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: """ try: - lspci_out = Popen(["lspci"], stdout=PIPE) - gpu_name: bytes = check_output( - ["grep", "-i", "VGA"], stdin=lspci_out.stdout + gpu_name: Optional[str] = exec_cmd( # type: ignore + log, + ["grep", "-i", "VGA"], + False, + False, + True, + ["lspci"] ) - lspci_out.wait() - if lspci_out.returncode != 0: - raise SystemExit(["lspci"], lspci_out.returncode) except (CalledProcessError, FileNotFoundError) as Err: log.logger("e", f"{Err}. Command lspci failed to execute.") return None else: return [ - gpu.split(":") for gpu in ( - gpu_name - .decode("utf-8") - .strip() - .split("\n") - ) + gpu.split(":") for gpu in gpu_name.split(r"\n") ] From 7fc8732c2dff098b291cab7617be7e1cf9d936a6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 29 Jan 2023 21:33:58 +0800 Subject: [PATCH 212/240] initial commit on kbd backlight #17 --- src/utils/core/system/laptop/kbd_backlight.py | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/utils/core/system/laptop/kbd_backlight.py b/src/utils/core/system/laptop/kbd_backlight.py index e69de29..c945163 100644 --- a/src/utils/core/system/laptop/kbd_backlight.py +++ b/src/utils/core/system/laptop/kbd_backlight.py @@ -0,0 +1,63 @@ +from glob import glob +from os.path import isfile +from typing import Optional, NoReturn + +from rich.console import Console + +from src.utils.shared.exec import exec_cmd +from src.utils.shared.misc.uinput import uinput +from src.utils.shared.log.logger import Logger + + +def kbd_backlit_support_check(log: Logger) -> str | None: + """Check if the device has a keyboard backlight. + + Returns: + A boolean value corresponding to whether the kbd backlight works + """ + + try: + file: str + for file in glob("/sys/class/leds"): + if isfile(file) and file.endswith("::kbd_backlight"): + return file + except (PermissionError, OSError, FileNotFoundError) as Err: + log.logger( + "E", + ( + f"{Err}. Cannot determine whether" + " the device supports backlight." + ) + ) + + return None + + +def check_kbd_backlit(log: Logger, console: Console) -> None | NoReturn: + """Check whether the kbd backlit works by default keybinding, + if not install brightnessctl and bind to a specific command.""" + + fname: Optional[str]; i: int + if fname := kbd_backlit_support_check(): + for i in range(1, 4): + exec_cmd( + log, + [ + "sudo", + "tee", + "-a", + f"/sys/class/leds/{fname}" + ], + False, + False, + True, + [ + "echo", + i + ] + ) + + if uinput(console, "Does the keyboard backlight work?", 1): + return True + + return False From 1c8d333482a83c06e5d6aaa478c82f38353cdd49 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 30 Jan 2023 18:54:14 +0800 Subject: [PATCH 213/240] install method --- INSTALLATION.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 INSTALLATION.md diff --git a/INSTALLATION.md b/INSTALLATION.md new file mode 100644 index 0000000..b6a3bbe --- /dev/null +++ b/INSTALLATION.md @@ -0,0 +1,26 @@ +# Installation + +**The project is currently in active development** + +The project is written in Python >= 3.11, and does not need to be compiled +however, the dependencies are needed to be installed in a $PATH accessible +by python. + +The authors recommend to install the project dependencies inside virtualbox +and test the project inside: + +``` +python3.11 -m venv venv +``` + +Then activate the virtual environment, and install the dependencies with: + +``` +python3.11 -m pip install -r REQUIREMENTS +``` + +And run the main module: + +``` +python -m src.main +``` From 59639fecb878cb4aa0d7a49f2e369b5b68ac2235 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 30 Jan 2023 18:55:12 +0800 Subject: [PATCH 214/240] update --- CODE_OF_CONDUCT.md | 3 ++- HACKING.md | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 03ea9d2..61c51a3 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -22,7 +22,8 @@ Examples of unacceptable behavior by participants include: ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org diff --git a/HACKING.md b/HACKING.md index 2f30273..50d5764 100644 --- a/HACKING.md +++ b/HACKING.md @@ -20,9 +20,9 @@ check if you have Python >= 3.10 with: python --version ``` -Although there can be workarounds, it is encouraged to use Python 3.10, but if not -possible, it is not enforced, upto Python >= 3.7 is acceptable. Then create a -virtual environment with +Although there can be workarounds, it is encouraged to use Python 3.10, +but if not possible, it is not enforced, upto Python >= 3.7 is acceptable. +Then create a virtual environment with ``` python -m venv venv @@ -47,8 +47,8 @@ for acceptable interactions with in the community. # Notes -1. All functions are documented with docstrings, [PEP 0257](https://peps.python.org/pep-0257/), -which takes a format of: +1. All functions are documented with docstrings, +[PEP 0257](https://peps.python.org/pep-0257/), which takes a format of: ```python def function(x: int) -> int: @@ -73,7 +73,7 @@ def function(x: int) -> int: return x*x ``` -2. Use comments, preferrably if you can use the Better Comments syntax, please do: +2. Use comments, preferrably if you can use the Better Comments syntax: ``` #! FOR URGENT/WARNING From 644ce3b3eed0b447f0704b54ba1b5358e9d2caa6 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Mon, 30 Jan 2023 18:57:17 +0800 Subject: [PATCH 215/240] check if mypy exists or not before executing the command --- check.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/check.sh b/check.sh index 6d61b04..819c180 100755 --- a/check.sh +++ b/check.sh @@ -1,4 +1,9 @@ #!/usr/bin/env bash +if [[ ! $(command -v mypy &> /dev/null) ]]; then + echo -e "\033[1;31mmypy==0.991 is not installed!" + exit 1 +fi + mypy --install-types mypy --strict $(git ls-files "*.py") --explicit-package-base From c9189fccec98e410755e6bc97b3053afbae49fe1 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 1 Feb 2023 14:12:59 +0800 Subject: [PATCH 216/240] check if the system is installed in ssd or not --- src/utils/core/system/optimizations/general_opt.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils/core/system/optimizations/general_opt.py b/src/utils/core/system/optimizations/general_opt.py index bdc55a5..db74168 100644 --- a/src/utils/core/system/optimizations/general_opt.py +++ b/src/utils/core/system/optimizations/general_opt.py @@ -47,6 +47,15 @@ def disable_services(self) -> None: def disable_workqueue(self) -> None: """Disable workqueue to improve ssd performance""" + def check_if_ssd() -> bool: + """Check if the system is installed on ssd or not. + + Returns + A boolean value pertaining to whether it is or not. + """ + + ... + disk_names: list[str] = [ parts.device for parts in disk_partitions() ] From 9a45f2ace10c8a18f9dc177df78636cad1e68d53 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 1 Feb 2023 14:22:24 +0800 Subject: [PATCH 217/240] include blkinfo==0.2.0 --- REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) diff --git a/REQUIREMENTS b/REQUIREMENTS index 0751eb3..c53bea1 100755 --- a/REQUIREMENTS +++ b/REQUIREMENTS @@ -1,3 +1,4 @@ rich==12.6.0 requests==2.28.1 psutil==5.9.4 +blkinfo==0.2.0 From 0a2a983dd0ced8f5ae2c2de381a964d3e59cb6dd Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 8 Feb 2023 01:03:51 +0800 Subject: [PATCH 218/240] fix ambigous name add_remove by renaming to setup.py --- src/utils/core/programs/{add_remove.py => setup.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/utils/core/programs/{add_remove.py => setup.py} (100%) diff --git a/src/utils/core/programs/add_remove.py b/src/utils/core/programs/setup.py similarity index 100% rename from src/utils/core/programs/add_remove.py rename to src/utils/core/programs/setup.py From fff8875760f796be6f13610166f0b0656c8d8630 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 8 Feb 2023 01:07:03 +0800 Subject: [PATCH 219/240] rename src.utils.core.programs to src.utils.core.program --- src/utils/core/{programs => program}/__init__.py | 0 src/utils/core/{programs => program}/setup.py | 0 src/utils/core/{programs => program}/tp_repo_install.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/utils/core/{programs => program}/__init__.py (100%) rename src/utils/core/{programs => program}/setup.py (100%) rename src/utils/core/{programs => program}/tp_repo_install.py (100%) diff --git a/src/utils/core/programs/__init__.py b/src/utils/core/program/__init__.py similarity index 100% rename from src/utils/core/programs/__init__.py rename to src/utils/core/program/__init__.py diff --git a/src/utils/core/programs/setup.py b/src/utils/core/program/setup.py similarity index 100% rename from src/utils/core/programs/setup.py rename to src/utils/core/program/setup.py diff --git a/src/utils/core/programs/tp_repo_install.py b/src/utils/core/program/tp_repo_install.py similarity index 100% rename from src/utils/core/programs/tp_repo_install.py rename to src/utils/core/program/tp_repo_install.py From 589d98cc8595073d09dcc625b2d9ab06910a89e8 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 8 Feb 2023 01:16:54 +0800 Subject: [PATCH 220/240] fix the erroneous checking of whether mypy exists or not --- check.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/check.sh b/check.sh index 819c180..c9529db 100755 --- a/check.sh +++ b/check.sh @@ -1,9 +1,6 @@ #!/usr/bin/env bash -if [[ ! $(command -v mypy &> /dev/null) ]]; then - echo -e "\033[1;31mmypy==0.991 is not installed!" - exit 1 -fi +command -v mypy >/dev/null 2>&1 || { echo -e "\033[1;31mmypy==0.991 is not installed!" && exit 1; } mypy --install-types mypy --strict $(git ls-files "*.py") --explicit-package-base From 77dfefd15ffa8e58f22e0ad174645ec03891504e Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 8 Feb 2023 01:33:23 +0800 Subject: [PATCH 221/240] fix type hint errors as well as other errors including - missing arguments - fix return values - remove unused # type: ignore - improve conditions - fix formatting of code --- src/utils/core/drv_codecs/gpu_install.py | 4 +- src/utils/core/system/laptop/kbd_backlight.py | 4 +- .../core/system/optimizations/general_opt.py | 31 ++++++++++++--- .../system/optimizations/variant_based_opt.py | 38 ++++++++++++------- src/utils/shared/exec.py | 12 +++--- 5 files changed, 60 insertions(+), 29 deletions(-) diff --git a/src/utils/core/drv_codecs/gpu_install.py b/src/utils/core/drv_codecs/gpu_install.py index 0f56bd1..b3a243f 100644 --- a/src/utils/core/drv_codecs/gpu_install.py +++ b/src/utils/core/drv_codecs/gpu_install.py @@ -21,7 +21,7 @@ def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: """ try: - gpu_name: Optional[str] = exec_cmd( # type: ignore + gpu_name: Optional[str] = exec_cmd( log, ["grep", "-i", "VGA"], False, @@ -35,7 +35,7 @@ def fetch_gpu(log: Logger) -> Optional[list[list[str]]]: return None else: return [ - gpu.split(":") for gpu in gpu_name.split(r"\n") + gpu.split(":") for gpu in gpu_name.split(r"\n") # type: ignore ] diff --git a/src/utils/core/system/laptop/kbd_backlight.py b/src/utils/core/system/laptop/kbd_backlight.py index c945163..5457de1 100644 --- a/src/utils/core/system/laptop/kbd_backlight.py +++ b/src/utils/core/system/laptop/kbd_backlight.py @@ -33,12 +33,12 @@ def kbd_backlit_support_check(log: Logger) -> str | None: return None -def check_kbd_backlit(log: Logger, console: Console) -> None | NoReturn: +def check_kbd_backlit(log: Logger, console: Console) -> bool | NoReturn: """Check whether the kbd backlit works by default keybinding, if not install brightnessctl and bind to a specific command.""" fname: Optional[str]; i: int - if fname := kbd_backlit_support_check(): + if fname := kbd_backlit_support_check(log): for i in range(1, 4): exec_cmd( log, diff --git a/src/utils/core/system/optimizations/general_opt.py b/src/utils/core/system/optimizations/general_opt.py index db74168..9de4608 100644 --- a/src/utils/core/system/optimizations/general_opt.py +++ b/src/utils/core/system/optimizations/general_opt.py @@ -2,6 +2,7 @@ from rich.console import Console from psutil import disk_partitions +from blkinfo import BlkDiskInfo # type: ignore from src.utils.shared.exec import exec_cmd from src.utils.shared.fetch_env import fetch_env @@ -47,7 +48,7 @@ def disable_services(self) -> None: def disable_workqueue(self) -> None: """Disable workqueue to improve ssd performance""" - def check_if_ssd() -> bool: + def check_if_ssd() -> bool: # type: ignore """Check if the system is installed on ssd or not. Returns @@ -56,9 +57,29 @@ def check_if_ssd() -> bool: ... - disk_names: list[str] = [ - parts.device for parts in disk_partitions() - ] + def check_if_encrypted() -> str | bool: # type: ignore + """Check if the devices are encrypted or not. + + Returns + if the device is encrypted, return the name of the device, + if otherwise, return false. + """ + + dev_name: str = [ + dev.device for dev in disk_partitions() + if ( + dev.device.startswith("/dev/mapper") + and dev.mountpoint.strip() == "/" + ) + ][0] #* get the first encrypted device mounted in / + + # if not dev_info : + # return False + + # dev_info: BlkDiskInfo = BlkDiskInfo().get_disks( + # { + # "name": + # } + # ) - for disks in disk_names: ... diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index 3c21dd9..eaa3cb6 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -13,7 +13,7 @@ def __init__(self, log: Logger, console: Console) -> None: self.log: Logger = log self.console: Console = console - def _fetch_variant(self) -> str: + def _fetch_variant(self) -> str | Any: """Fetch the name of variant using /etc/os-release Returns: @@ -34,27 +34,35 @@ def _fetch_variant(self) -> str: except (FileNotFoundError, PermissionError) as Err: self.log.logger("E", f"{Err}. Cannot find /etc/os-release file.") - return uinput( - self.console, - "Kindly input the Fedora OSTree variant you are using", - 3 - ) + return uinput( + self.console, + "Kindly input the Fedora OSTree variant you are using", + 3 + ) - def remove_base_programs(self, variant: str) -> NoReturn | None: + def remove_base_programs(self, variant: str) -> NoReturn | None: # type: ignore """Remove programs layered in base image of a given variant.""" base_programs: dict[str, list[str]] = { - "kinoite": [], - "silverblue": [], - "vauxite": [] #! from what ive heard this variant is still not yet official + "kinoite": [ + "" + ], + "silverblue": [ + "" + ], + "vauxite": [ #! from what ive heard this variant is still not yet official + "" + ] } - def sys_opt(self, variant: str) -> NoReturn | None: + def sys_opt(self, variant: str) -> NoReturn | None: # type: ignore """Removal/alteration of default settings that are known to be detrimental in terms of performance.""" - sys_opts: dict[str, list[str]] = { - "kinoite": [], + sys_opts: dict[str, list[str | list[str]]] = { + "kinoite": [ + "" + ], "silverblue": [ [ # disable gnome software from autostart "sudo", @@ -62,5 +70,7 @@ def sys_opt(self, variant: str) -> NoReturn | None: "/etc/xdg/autostart/org.gnome.Software.desktop" ] ], - "vauxite": [] + "vauxite": [ + "" + ] } diff --git a/src/utils/shared/exec.py b/src/utils/shared/exec.py index 0a2e8e2..2e98c17 100755 --- a/src/utils/shared/exec.py +++ b/src/utils/shared/exec.py @@ -7,18 +7,18 @@ PIPE, check_output ) -from typing import NoReturn, Optional +from typing import NoReturn, Optional, Any from src.utils.shared.log.logger import Logger def exec_cmd( log: Logger, - cmd: list[str], + cmd: list[Any], verbose: bool = False, break_proc: bool = False, pipe_: bool = False, - init_cmd: Optional[list[str]] = None + init_cmd: Optional[list[Any]] = None ) -> NoReturn | None | str: """For command execution/system calls with error handling @@ -41,11 +41,11 @@ def exec_cmd( ) raise SystemExit - if pipe_: + if pipe_ and init_cmd: init_cmd_out = Popen(init_cmd, stdout=PIPE) pipe_cmd: bytes = check_output( - cmd, stdin=init_cmd_out.stdout - ) + cmd, stdin=init_cmd_out.stdout + ) init_cmd_out.wait() if init_cmd_out.returncode != 0: From 8fc376cb4e2dc8b6d76672a49f58180af356c483 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Wed, 8 Feb 2023 01:36:24 +0800 Subject: [PATCH 222/240] include stubs for psutil, types-psutil==5.9.5.6 --- DEV_REQUIREMENTS | 1 + 1 file changed, 1 insertion(+) diff --git a/DEV_REQUIREMENTS b/DEV_REQUIREMENTS index 95ebfdf..8b554cd 100755 --- a/DEV_REQUIREMENTS +++ b/DEV_REQUIREMENTS @@ -1,2 +1,3 @@ mypy==0.991 types-requests==2.28.11.7 +types-psutil==5.9.5.6 From 1ce88ad2f015fbd5264508059f22ccccc7836052 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 13:43:51 +0800 Subject: [PATCH 223/240] moved to asses/tests --- assets/{ => tests}/test_block-app_remove | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename assets/{ => tests}/test_block-app_remove (100%) diff --git a/assets/test_block-app_remove b/assets/tests/test_block-app_remove similarity index 100% rename from assets/test_block-app_remove rename to assets/tests/test_block-app_remove From 4fc514fe20599baea53c460bc6e7b0721b59c824 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 13:56:02 +0800 Subject: [PATCH 224/240] create archives folder for organization --- {scripts => archives/scripts}/script1.sh | 0 {scripts => archives/scripts}/script2.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {scripts => archives/scripts}/script1.sh (100%) rename {scripts => archives/scripts}/script2.sh (100%) diff --git a/scripts/script1.sh b/archives/scripts/script1.sh similarity index 100% rename from scripts/script1.sh rename to archives/scripts/script1.sh diff --git a/scripts/script2.sh b/archives/scripts/script2.sh similarity index 100% rename from scripts/script2.sh rename to archives/scripts/script2.sh From 57733282bad45b4a8fc131cccc90067913936975 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:04:08 +0800 Subject: [PATCH 225/240] shorten lines to 72 char --- src/utils/conf/fetch_config.py | 25 +++++++++++++------ src/utils/conf/load_conf.py | 13 +++++++--- src/utils/core/program/setup.py | 3 ++- src/utils/core/program/tp_repo_install.py | 17 +++++++++---- .../core/system/optimizations/general_opt.py | 3 ++- .../system/optimizations/variant_based_opt.py | 9 +++++-- src/utils/shared/log/logger.py | 3 ++- src/utils/shared/misc/uinput.py | 12 ++++++--- 8 files changed, 60 insertions(+), 25 deletions(-) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/fetch_config.py index 1d6a8d3..e2b7460 100644 --- a/src/utils/conf/fetch_config.py +++ b/src/utils/conf/fetch_config.py @@ -23,16 +23,19 @@ def fetch_missing_config( if not conf_links: conf_links = { "app_for_install": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_install.json" + "https://raw.githubusercontent.com/" + "iaacornus/Fedora-OSTree-Setup/" + "devel/config/app_for_install.json" ), "app_for_removal": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/app_for_removal.json" + "https://raw.githubusercontent.com/" + "iaacornus/Fedora-OSTree-Setup/" + "devel/config/app_for_removal.json" ), "ostree_setup": ( - "https://raw.githubusercontent.com/iaacornus/Fedora-" - "OSTree-Setup/devel/config/ostree_setup.json" + "https://raw.githubusercontent.com/" + "iaacornus/Fedora-OSTree-Setup/" + "devel/config/ostree_setup.json" ) } @@ -40,11 +43,17 @@ def fetch_missing_config( for attempt in range(3): try: log.logger( - "I", f"Fetching the config file ({conf_name}) from Github." + "I", ( + "Fetching the config file " + f"({conf_name}) from Github." + ) ) if not (conf_link := conf_links.get(conf_name)): log.logger( - "E", f"Cannot fetch the config: {conf_name}, aborting ..." + "E", ( + "Cannot fetch the config: " + f"{conf_name}, aborting ..." + ) ) raise SystemExit diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/load_conf.py index 039ed6c..86a7baa 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/load_conf.py @@ -23,8 +23,8 @@ def __init__(self, log: Logger) -> None: self.log: Logger = log def check_missing(self) -> NoReturn | None: - """Checks the config file if missing or not, if missing fetch the - original config file from the repository.""" + """Checks the config file if missing or not, if missing + fetch the original config file from the repository.""" if not isdir(self.CONF_PATH): try: @@ -38,7 +38,9 @@ def check_missing(self) -> NoReturn | None: conf_name: str for conf_name in self.CONF_ARR: if not exists(f"{self.CONF_PATH}/{conf_name}.json"): - fetch_missing_config(self.log, conf_name, self.CONF_PATH) + fetch_missing_config( + self.log, conf_name, self.CONF_PATH + ) return None @@ -59,7 +61,10 @@ def load_conf(self) -> ConfigValues | NoReturn: ) except (FileNotFoundError, PermissionError) as Err: self.log.logger( - "I", f"{Err}. Can't open config file, run the program again." + "I", ( + f"{Err}. Can't open config" + "file, run the program again." + ) ) else: return parsed_conf diff --git a/src/utils/core/program/setup.py b/src/utils/core/program/setup.py index 6436b08..003e9ab 100644 --- a/src/utils/core/program/setup.py +++ b/src/utils/core/program/setup.py @@ -67,7 +67,8 @@ def _enum_prog( progdata: ProgData, progtype: str ) -> Any: - """Enumerate the programs in the list and print out with a format. + """Enumerate the programs in the list and print out with a + format. Args: progindex -- ind of applications and their name diff --git a/src/utils/core/program/tp_repo_install.py b/src/utils/core/program/tp_repo_install.py index 0417a92..039a2f8 100644 --- a/src/utils/core/program/tp_repo_install.py +++ b/src/utils/core/program/tp_repo_install.py @@ -3,7 +3,9 @@ from src.utils.shared.misc.uinput import uinput -def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: +def tp_repo_install( + console: Console + ) -> tuple[list[list[str]], list[str]]: """Install third party repositories. Args: @@ -16,8 +18,9 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: 1: { "name": "rpm_RPMFusion Free", "desc": ( - "Software that uses a free license, but is " - "not accepted in Fedora for various reasons." + "Software that uses a free " + "license, but is not accepted " + "in Fedora for various reasons." ), "address": ( r"https://mirrors.rpmfusion.org/" @@ -40,7 +43,10 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: 3: { "name": "fp_Flathub", "desc": "Unfiltered repository for flatpaks.", - "address": "https://flathub.org/repo/flathub.flatpakrepo" + "address": ( + "https://flathub.org/repo" + "/flathub.flatpakrepo" + ) }, 4: { "name": "fp_Fedora OCI", @@ -51,7 +57,8 @@ def tp_repo_install(console: Console) -> tuple[list[list[str]], list[str]]: "name": "fp_KDE", "desc": "KDE Applications.", "address": ( - "https://distribute.kde.org/kdeapps.flatpakrepo" + "https://distribute.kde.org/" + "skdeapps.flatpakrepo" ) }, 6: { diff --git a/src/utils/core/system/optimizations/general_opt.py b/src/utils/core/system/optimizations/general_opt.py index 9de4608..f9b8f67 100644 --- a/src/utils/core/system/optimizations/general_opt.py +++ b/src/utils/core/system/optimizations/general_opt.py @@ -61,7 +61,8 @@ def check_if_encrypted() -> str | bool: # type: ignore """Check if the devices are encrypted or not. Returns - if the device is encrypted, return the name of the device, + if the device is encrypted, return the name of the + device, if otherwise, return false. """ diff --git a/src/utils/core/system/optimizations/variant_based_opt.py b/src/utils/core/system/optimizations/variant_based_opt.py index eaa3cb6..8dfa546 100644 --- a/src/utils/core/system/optimizations/variant_based_opt.py +++ b/src/utils/core/system/optimizations/variant_based_opt.py @@ -32,7 +32,9 @@ def _fetch_variant(self) -> str | Any: .replace(r"\n", "") ) except (FileNotFoundError, PermissionError) as Err: - self.log.logger("E", f"{Err}. Cannot find /etc/os-release file.") + self.log.logger( + "E", f"{Err}. Cannot find /etc/os-release file." + ) return uinput( self.console, @@ -67,7 +69,10 @@ def sys_opt(self, variant: str) -> NoReturn | None: # type: ignore [ # disable gnome software from autostart "sudo", "rm", - "/etc/xdg/autostart/org.gnome.Software.desktop" + ( + "/etc/xdg/autostart/" + "org.gnome.Software.desktop" + ) ] ], "vauxite": [ diff --git a/src/utils/shared/log/logger.py b/src/utils/shared/log/logger.py index 25cf90c..555655d 100755 --- a/src/utils/shared/log/logger.py +++ b/src/utils/shared/log/logger.py @@ -49,7 +49,8 @@ def __init__(self, filename: str = "log") -> None: self.log.addHandler(file_log) def logger(self, exception_: str, message: str) -> None: - """Log the proccesses using passed message and exception_ variable. + """Log the proccesses using passed message and exception_ + variable. Args: exception_ -- determines what type of log level to use diff --git a/src/utils/shared/misc/uinput.py b/src/utils/shared/misc/uinput.py index 0974a92..409fb25 100755 --- a/src/utils/shared/misc/uinput.py +++ b/src/utils/shared/misc/uinput.py @@ -9,7 +9,8 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: Args: console -- Console instance msg -- question to ask the user - qtype -- question type, whether y/N, string input or number input + qtype -- question type, whether y/N, string input or number + input 1 is yes or no input 2 is number/list input 3 is for string or char input @@ -24,7 +25,12 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: match qtype: case 1: console.print( - f"{msg} [bold][[green]y[/green]/[red]N[/red]][/bold]", end=" " + ( + f"{msg} " + "[bold][[green]y[/green]/" + "[red]N[/red]][/bold]" + ), + end=" " ) if input().lower().strip() == "y": return True @@ -44,6 +50,6 @@ def uinput(console: Console, msg: str, qtype: int) -> Any: ", separate by comma ','][/bold]" ), end=" " ) - return input().strip().lower().replace(r"\n", "") + return input().strip().lower().replace(r"\n", "") return False From ae10533dd47501c66dbfdf38fb1e0d65b92334b4 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:08:56 +0800 Subject: [PATCH 226/240] shorten lines to 72 char --- CODE_OF_CONDUCT.md | 20 +++++++++++--------- CONTRIBUTING.md | 36 +++++++++++++++++++----------------- HACKING.md | 32 +++++++++++++++++--------------- INSTALLATION.md | 13 +++++++------ README.md | 16 ++++++++-------- docs/README.md | 3 ++- docs/project_struct.md | 22 ++++++++++++---------- 7 files changed, 76 insertions(+), 66 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 61c51a3..4ec22e6 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -11,19 +11,21 @@ include: Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery and unwelcome sexual +attention or advances +* Trolling, insulting/derogatory comments, and personal or political +attacks * Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission +* Publishing others' private information, such as a physical or +electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a - professional setting +professional setting ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html +This Code of Conduct is adapted from the +[Contributor Covenant][homepage], version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 785bda9..3f90748 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,23 +1,22 @@ # Contribution -All pull requests are welcome, however, do note that the maintainer of the -project is a full time university student, thus may not be able to respond as -fast as you may expect. +All pull requests are welcome, however, do note that the maintainer of +the project is a full time university student, thus may not be able to +respond as fast as you may expect. # Notes -1. If you are planning to introduce a big change in codebase, open an issue -first for discussion, that waste of time would be avoided. +1. If you are planning to introduce a big change in codebase, open an +issue first for discussion, that waste of time would be avoided. -2. The project is currently written in Python 3.10, with strict compliance to -[PEP-0008](https://peps.python.org/pep-0008/) in terms of formatting, and to -[PEP-0257](https://peps.python.org/pep-0257/) in regards of docstring -formatting, with slight modification for sake of consistency: +2. The project is currently written in Python 3.10, with strict +compliance to [PEP-0008](https://peps.python.org/pep-0008/) in terms of +formatting, and to [PEP-0257](https://peps.python.org/pep-0257/) in +regards of docstring formatting, with slight modification for sake of +consistency. The modifications include: -The modifications include: - -In lists, as well as declaration of variables, there is always indent after -line break: +In lists, as well as declaration of variables, there is always indent +after line break: ```python hello_world: list[str] = [ @@ -39,11 +38,14 @@ hello_from_long_function( ) ``` -Rules to type checking is provided by [PEP-0484](https://peps.python.org/pep-0484/), -and is checked by [`mypy`](https://github.com/python/mypy), which requires +Moreover, the project strictly requires lines to be limited to 72 chars. + +Rules to type checking is provided by +[PEP-0484](https://peps.python.org/pep-0484/), and is checked by +[`mypy`](https://github.com/python/mypy), which requires `type-setuptools` and `type-requests`. -3. Be sure to run the checks and test your code first before opening pull -requests, the unit test can be invoked with `./check.sh`. +3. Be sure to run the checks and test your code first before opening +pull requests, the unit test can be invoked with `./check.sh`. 4. Always comply to [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md). diff --git a/HACKING.md b/HACKING.md index 14171b6..c39c54d 100644 --- a/HACKING.md +++ b/HACKING.md @@ -1,7 +1,8 @@ # HACKING -To setup the project, clone the `devel` branch of the repository and create -your own branch with the name of feature/issue you want to introduce/work on: +To setup the project, clone the `devel` branch of the repository and +create your own branch with the name of feature/issue you want to +introduce/work on: ``` git clone -b devel https://github.com/iaacornus/Fedora-OSTree-Setup @@ -13,16 +14,16 @@ Then git branch ``` -The project is using Python >= 3.10, preferrably 3.11, thus to start working on -check if you have Python >= 3.10 with: +The project is using Python >= 3.10, preferrably 3.11, thus to start +working on check if you have Python >= 3.10 with: ``` python --version ``` Although there can be workarounds, it is encouraged to use Python 3.10, -but if not possible, it is not enforced, upto Python >= 3.7 is acceptable. -Then create a virtual environment with +but if not possible, it is not enforced, upto Python >= 3.7 is +acceptable. Then create a virtual environment with ``` python -m venv venv @@ -34,16 +35,17 @@ Source it and start installing dependencies with pip install -r DEV_REQUIREMENTS && pip install -r REQUIREMENTS ``` -_Note that in other system `pip3` or `pip` is used instead, -e.g. `pip3.11`._ +_Note that in other system `pip3` or `pip` is used +instead, e.g. `pip3.11`._ -`DEV_REQUIREMENTS` include the modules needed for test, specifically `mypy` and -the `types` of other third party modules, while `REQUIREMENTS` contains the -modules used by project. +`DEV_REQUIREMENTS` include the modules needed for test, specifically +`mypy` and the `types` of other third party modules, while +`REQUIREMENTS` contains the modules used by project. -Finally start working in the project, refer to [CONTRIBUTING.md](CONTRIBUTING.md) -for guidelines about code formatting and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) -for acceptable interactions with in the community. +Finally start working in the project, refer to +[CONTRIBUTING.md](CONTRIBUTING.md) for guidelines about code formatting +and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for acceptable +interactions with in the community. # Notes @@ -83,4 +85,4 @@ def function(x: int) -> int: ``` 3. Browse `/docs/` for further documentation of the project structure, -functions, classes and the code itself. \ No newline at end of file +functions, classes and the code itself. diff --git a/INSTALLATION.md b/INSTALLATION.md index b6a3bbe..d1db88d 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -2,18 +2,19 @@ **The project is currently in active development** -The project is written in Python >= 3.11, and does not need to be compiled -however, the dependencies are needed to be installed in a $PATH accessible -by python. +The project is written in Python >= 3.11, and does not need to be +compiled however, the dependencies are needed to be installed in a +`$PATH` accessible by python. -The authors recommend to install the project dependencies inside virtualbox -and test the project inside: +The authors recommend to install the project dependencies inside +virtualbox and test the project inside: ``` python3.11 -m venv venv ``` -Then activate the virtual environment, and install the dependencies with: +Then activate the virtual environment, and install the dependencies +with: ``` python3.11 -m pip install -r REQUIREMENTS diff --git a/README.md b/README.md index 8140385..b09c120 100755 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Fedora-OSTree-Setup -A python-program that automates the setup of Fedora Silverblue/Kinoite based -on given config file. +A python-program that automates the setup of Fedora Silverblue/Kinoite +based on given config file. # Contributing -All contributions whether small or large is welcome! Just fork the project and -create a pull request when done. +All contributions whether small or large is welcome! Just fork the +project and create a pull request when done. -Refer to [HACKING.md](HACKING.md) to start in how to setup the project, then in -[CONTRIBUTING.md](CONTRIBUTING.md) for protocols/guidelines to follow, and take -a browse in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) to see what is the acceptable -behavior in the community. +Refer to [HACKING.md](HACKING.md) to start in how to setup the project, +then in [CONTRIBUTING.md](CONTRIBUTING.md) for protocols/guidelines to +follow, and take a browse in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) +to see what is the acceptable behavior in the community. diff --git a/docs/README.md b/docs/README.md index 7a22262..0649bdf 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,4 @@ # DOCUMENTATION -This directory contains all the documentation about the project codebase. +This directory contains all the documentation about the project +codebase. diff --git a/docs/project_struct.md b/docs/project_struct.md index eea4ef2..e8ded5d 100644 --- a/docs/project_struct.md +++ b/docs/project_struct.md @@ -14,24 +14,26 @@ src `-- misc ``` -`src/` contains the source code of the program, which is further broken down into: +`src/` contains the source code of the program, which is further broken +down into: -1. `interface`, where the front-end related codes are stored, particularly -the commandline interface. +1. `interface`, where the front-end related codes are stored, +particularly the commandline interface. -2. `misc` are where the not really important codes are stored such as type aliases. +2. `misc` are where the not really important codes are stored such as +type aliases. -3. `utils` where the functions that is called in `main.py` is stored, which is -further broken down into: +3. `utils` where the functions that is called in `main.py` is stored, +which is further broken down into: -a. `conf` are everything related to the functions that deal with the config -file of the program. +a. `conf` are everything related to the functions that deal with the +config file of the program. b. `core` are the most crucial piece that executes each feature such as removal of applications as well as installation. -c. `shared` are where the self written modules called by different modules in -`core` are stored, this is further broken down into: +c. `shared` are where the self written modules called by different +modules in `core` are stored, this is further broken down into: 1. `log`, the logging system. From 240e7c5e274cc0b3f715f3d3dd6469d3cb9b2446 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:24:37 +0800 Subject: [PATCH 227/240] include id for identification of repo the name is also used for display instead --- src/utils/core/program/tp_repo_install.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/utils/core/program/tp_repo_install.py b/src/utils/core/program/tp_repo_install.py index 039a2f8..b25d356 100644 --- a/src/utils/core/program/tp_repo_install.py +++ b/src/utils/core/program/tp_repo_install.py @@ -17,6 +17,7 @@ def tp_repo_install( # id and name of the repo and the address 1: { "name": "rpm_RPMFusion Free", + "id": "rpm_rfusion_f" "desc": ( "Software that uses a free " "license, but is not accepted " @@ -30,6 +31,7 @@ def tp_repo_install( }, 2: { "name": "rpm_RPMFusion Non-free", + "id": "rpm_rfusion_nf", "desc": ( "Software that uses a nonfree " "license, but is otherwise redistributable." @@ -42,6 +44,7 @@ def tp_repo_install( }, 3: { "name": "fp_Flathub", + "id": "fp_flathub", "desc": "Unfiltered repository for flatpaks.", "address": ( "https://flathub.org/repo" @@ -49,12 +52,14 @@ def tp_repo_install( ) }, 4: { - "name": "fp_Fedora OCI", + "name": "Fedora OCI (Flatpak)", + "id": "fp_fed_oci", "desc": "For Open Containers Initiative (OCI)", #? what's this for? "address": "oci+https://registry.fedoraproject.org" }, 5: { - "name": "fp_KDE", + "name": "KDE (Flatpak)", + "id": "fp_kde", "desc": "KDE Applications.", "address": ( "https://distribute.kde.org/" @@ -62,7 +67,8 @@ def tp_repo_install( ) }, 6: { - "name": "fp_GNOME Nightly", + "name": "GNOME Nightly (Flatpak)", + "id": "fp_gnome_nightly", "desc": "For cutting edge builds from GNOME.", "address": ( "https://nightly.gnome.org/" @@ -70,7 +76,8 @@ def tp_repo_install( ) }, 7: { - "name": "rpm_RPMFusion Free (Tainted)", + "name": "RPMFusion Free (Tainted)", + "id": "rpm_rfusion_f_tainted", "desc": ( "Software that use a free license, but may" " have usage restriction in some countries" @@ -78,7 +85,8 @@ def tp_repo_install( "address": "rpmfusion-free-release-tainted" }, 8: { - "name": "rpm_RPMFusion Non-free (Tainted)", + "name": "RPMFusion Non-free (Tainted)", + "id": "rpm_rfusion_nf_tainted", "desc": ( "Software that uses a nonfree license and " "which is not explicitly redistributable, " From 4cac247ecc91f3802c8cf1600a2512364f0e05de Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:27:02 +0800 Subject: [PATCH 228/240] update conditions --- src/utils/core/program/tp_repo_install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/core/program/tp_repo_install.py b/src/utils/core/program/tp_repo_install.py index b25d356..b276969 100644 --- a/src/utils/core/program/tp_repo_install.py +++ b/src/utils/core/program/tp_repo_install.py @@ -17,7 +17,7 @@ def tp_repo_install( # id and name of the repo and the address 1: { "name": "rpm_RPMFusion Free", - "id": "rpm_rfusion_f" + "id": "rpm_rfusion_f", "desc": ( "Software that uses a free " "license, but is not accepted " @@ -106,8 +106,8 @@ def tp_repo_install( f"Install {repo.get('name')} ({repo.get('desc')})", 1 ): - repo_name: str = repo.get("name") # type: ignore - if repo_name.startswith("fp_"): + repo_id: str = repo.get("id") # type: ignore + if repo_id.startswith("fp_"): t_fp_cmd.append( [ "flatpak", From c4b8a36d3dbd2817844864eb0747ba3c0c6bb9a8 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:31:19 +0800 Subject: [PATCH 229/240] update sequence of items in dict --- src/utils/core/program/tp_repo_install.py | 46 +++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/utils/core/program/tp_repo_install.py b/src/utils/core/program/tp_repo_install.py index b276969..57c3043 100644 --- a/src/utils/core/program/tp_repo_install.py +++ b/src/utils/core/program/tp_repo_install.py @@ -41,8 +41,28 @@ def tp_repo_install( r"nonfree/fedora/rpmfusion-nonfree" r"-release-$(rpm -E %fedora).noarch.rpm" ) + }, + 7: { + "name": "RPMFusion Free (Tainted)", + "id": "rpm_rfusion_f_tainted", + "desc": ( + "Software that use a free license, but may" + " have usage restriction in some countries" + ), + "address": "rpmfusion-free-release-tainted" }, 3: { + "name": "RPMFusion Non-free (Tainted)", + "id": "rpm_rfusion_nf_tainted", + "desc": ( + "Software that uses a nonfree license and " + "which is not explicitly redistributable, " + "but is allowed for inter-operability " + "purposes in some countries." + ), + "address": "rpmfusion-nonfree-release-tainted" + }, + 4: { "name": "fp_Flathub", "id": "fp_flathub", "desc": "Unfiltered repository for flatpaks.", @@ -51,13 +71,13 @@ def tp_repo_install( "/flathub.flatpakrepo" ) }, - 4: { + 5: { "name": "Fedora OCI (Flatpak)", "id": "fp_fed_oci", "desc": "For Open Containers Initiative (OCI)", #? what's this for? "address": "oci+https://registry.fedoraproject.org" }, - 5: { + 6: { "name": "KDE (Flatpak)", "id": "fp_kde", "desc": "KDE Applications.", @@ -66,7 +86,7 @@ def tp_repo_install( "skdeapps.flatpakrepo" ) }, - 6: { + 7: { "name": "GNOME Nightly (Flatpak)", "id": "fp_gnome_nightly", "desc": "For cutting edge builds from GNOME.", @@ -75,26 +95,6 @@ def tp_repo_install( "gnome-nightly.flatpakrepo" ) }, - 7: { - "name": "RPMFusion Free (Tainted)", - "id": "rpm_rfusion_f_tainted", - "desc": ( - "Software that use a free license, but may" - " have usage restriction in some countries" - ), - "address": "rpmfusion-free-release-tainted" - }, - 8: { - "name": "RPMFusion Non-free (Tainted)", - "id": "rpm_rfusion_nf_tainted", - "desc": ( - "Software that uses a nonfree license and " - "which is not explicitly redistributable, " - "but is allowed for inter-operability " - "purposes in some countries." - ), - "address": "rpmfusion-nonfree-release-tainted" - } } t_fp_cmd: list[list[str]] = [] From 391338ffe93fd901785c22f9d6b6b2f4301dd9ad Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:35:05 +0800 Subject: [PATCH 230/240] include some settings for v0.1 --- config/ostree_setup.json | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index 9511f55..150a5e0 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -1,4 +1,28 @@ { - "app_for_install_conf": "https://raw.githubusercontent.com/iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", - "app_for_uninstall_conf": "https://raw.githubusercontent.com/iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json" + "app_for_install_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", + "app_for_uninstall_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json", + "tp_repo_install": [ + "rpm_rfusion_f", + "rpm_rfusion_nf", + "rpm_rfusion_tainted", + "rpm_rfusion_nf_tained", + "fp_flathub", + "fp_fed_oci", + "fp_kde", + "fp_gnome_nightly" + ], + "install_c_drv": true, + "disable_wq_ssd": true, + "replace_toolbox": true, + "enable_wayland_in_ff": true, + "replacement_firefox_rpm": true, + "replace_ppd": true, + "s2idle-deep": true, + "battery_threshold": 80, + "remove_bpkg": true, + "bash-fish": true, + "mod_fish": { + "greetings": null + }, + "reinstall_rfusion": true } From f9508388bb8cd696806e9f609d407bb16d4f5ed3 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:39:13 +0800 Subject: [PATCH 231/240] include some settings for v0.1, initial commit for #59 --- config/ostree_setup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index 150a5e0..f4518c1 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -4,7 +4,7 @@ "tp_repo_install": [ "rpm_rfusion_f", "rpm_rfusion_nf", - "rpm_rfusion_tainted", + "rpm_rfusion_f_tainted", "rpm_rfusion_nf_tained", "fp_flathub", "fp_fed_oci", From 72628a242aa3c334a3488f3bd5dcfe89b21560e0 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:48:30 +0800 Subject: [PATCH 232/240] update names of params --- config/ostree_setup.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index f4518c1..d7d32c0 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -1,28 +1,28 @@ { - "app_for_install_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", - "app_for_uninstall_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json", - "tp_repo_install": [ + "afi_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", + "afu_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json", + "tprepo_i": [ "rpm_rfusion_f", "rpm_rfusion_nf", - "rpm_rfusion_f_tainted", + "rpm_rfusion_tainted", "rpm_rfusion_nf_tained", "fp_flathub", "fp_fed_oci", "fp_kde", "fp_gnome_nightly" ], - "install_c_drv": true, - "disable_wq_ssd": true, - "replace_toolbox": true, - "enable_wayland_in_ff": true, - "replacement_firefox_rpm": true, - "replace_ppd": true, - "s2idle-deep": true, - "battery_threshold": 80, - "remove_bpkg": true, - "bash-fish": true, + "cdrv_i": true, + "d_wq_ssd": true, + "r_toolbox": true, + "e_wayland_ff": true, + "r_ff_rpm": true, + "r_ppd": true, + "sw_deep": true, + "batt_thresh": 80, + "r_bpkgs": true, + "sw_fish": true, "mod_fish": { "greetings": null }, - "reinstall_rfusion": true + "ri_rfusion": true } From b15105f7fd95f3e1156b05fd20d12ae001937f0d Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:50:55 +0800 Subject: [PATCH 233/240] update module names corresponding to names of params in conf --- src/utils/conf/{fetch_config.py => conf-f.py} | 0 src/utils/conf/{load_conf.py => conf-l.py} | 2 +- src/utils/core/drv_codecs/{codecs.py => codecs-i.py} | 0 src/utils/core/drv_codecs/{gpu_install.py => gpu_drv-i.py} | 0 src/utils/core/program/{tp_repo_install.py => tprepo-i.py} | 0 .../core/system/laptop/{battery_thresh.py => batt_thresh.py} | 0 src/utils/core/system/{change_shell.py => sw_shell.py} | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename src/utils/conf/{fetch_config.py => conf-f.py} (100%) rename src/utils/conf/{load_conf.py => conf-l.py} (97%) rename src/utils/core/drv_codecs/{codecs.py => codecs-i.py} (100%) rename src/utils/core/drv_codecs/{gpu_install.py => gpu_drv-i.py} (100%) rename src/utils/core/program/{tp_repo_install.py => tprepo-i.py} (100%) rename src/utils/core/system/laptop/{battery_thresh.py => batt_thresh.py} (100%) rename src/utils/core/system/{change_shell.py => sw_shell.py} (100%) diff --git a/src/utils/conf/fetch_config.py b/src/utils/conf/conf-f.py similarity index 100% rename from src/utils/conf/fetch_config.py rename to src/utils/conf/conf-f.py diff --git a/src/utils/conf/load_conf.py b/src/utils/conf/conf-l.py similarity index 97% rename from src/utils/conf/load_conf.py rename to src/utils/conf/conf-l.py index 86a7baa..8a65150 100644 --- a/src/utils/conf/load_conf.py +++ b/src/utils/conf/conf-l.py @@ -4,7 +4,7 @@ from json import load from typing import NoReturn -from src.utils.conf.fetch_config import fetch_missing_config +from utils.conf.fetch_conf import fetch_missing_config from src.utils.shared.log.logger import Logger from src.misc.alias import ConfigValues diff --git a/src/utils/core/drv_codecs/codecs.py b/src/utils/core/drv_codecs/codecs-i.py similarity index 100% rename from src/utils/core/drv_codecs/codecs.py rename to src/utils/core/drv_codecs/codecs-i.py diff --git a/src/utils/core/drv_codecs/gpu_install.py b/src/utils/core/drv_codecs/gpu_drv-i.py similarity index 100% rename from src/utils/core/drv_codecs/gpu_install.py rename to src/utils/core/drv_codecs/gpu_drv-i.py diff --git a/src/utils/core/program/tp_repo_install.py b/src/utils/core/program/tprepo-i.py similarity index 100% rename from src/utils/core/program/tp_repo_install.py rename to src/utils/core/program/tprepo-i.py diff --git a/src/utils/core/system/laptop/battery_thresh.py b/src/utils/core/system/laptop/batt_thresh.py similarity index 100% rename from src/utils/core/system/laptop/battery_thresh.py rename to src/utils/core/system/laptop/batt_thresh.py diff --git a/src/utils/core/system/change_shell.py b/src/utils/core/system/sw_shell.py similarity index 100% rename from src/utils/core/system/change_shell.py rename to src/utils/core/system/sw_shell.py From 9a6e2f02840ac20c148b8a70257708529ff59d2f Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sat, 4 Mar 2023 14:52:56 +0800 Subject: [PATCH 234/240] use a subject-action format in name of params --- config/ostree_setup.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index d7d32c0..bdd6d3f 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -1,7 +1,7 @@ { "afi_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", "afu_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json", - "tprepo_i": [ + "tprepo-i": [ "rpm_rfusion_f", "rpm_rfusion_nf", "rpm_rfusion_tainted", @@ -11,18 +11,18 @@ "fp_kde", "fp_gnome_nightly" ], - "cdrv_i": true, - "d_wq_ssd": true, - "r_toolbox": true, - "e_wayland_ff": true, - "r_ff_rpm": true, - "r_ppd": true, - "sw_deep": true, + "cdrv-i": true, + "wq_ssd-d": true, + "toolbox-r": true, + "wayland_ff-e": true, + "ff_rpm-r": true, + "ppd-r": true, + "deep-sw": true, "batt_thresh": 80, - "r_bpkgs": true, - "sw_fish": true, - "mod_fish": { + "bpkgs-r": true, + "fish-s": true, + "fish-mod": { "greetings": null }, - "ri_rfusion": true + "rfusion-ri": true } From 9d72dff3c22317399c494f9703bc1e4684ebe617 Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sat, 4 Mar 2023 18:46:53 +0000 Subject: [PATCH 235/240] added more configs, extended some names, reordered thanks for the syntax! --- config/ostree_setup.json | 56 +++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index bdd6d3f..d0183b8 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -11,18 +11,62 @@ "fp_kde", "fp_gnome_nightly" ], + "KDE": false, + "disable-gui-software": true, + "rm-firefox-rpm": true, "cdrv-i": true, "wq_ssd-d": true, - "toolbox-r": true, + "toolbox-replace": true, "wayland_ff-e": true, - "ff_rpm-r": true, "ppd-r": true, "deep-sw": true, - "batt_thresh": 80, "bpkgs-r": true, - "fish-s": true, + "fish-setup": true, "fish-mod": { - "greetings": null + "greetings": null, }, - "rfusion-ri": true + "rfusion-ri": true, + "add-fonts": { + "msfonts": true, + "noto-color-emoji": true, + "apple-emoji": false, + }, + "waydroid": { + "waydroid-setup": true, + "waydroid-folders": true, + "waydroid-freeform": true, + }, + "hardware": { + "laptop": true, + "thinkpad": false, + "framework": false, + "tuxedo": false, + "amd": false, + "intel": false, + "nvidia": false, + "intel-mesa": false, + "keyb-backlight": false, + "fprint-sensor": false, + "battery-thresh": 80, + }, + "helperlinks": { + "standard-dirs": true, + "advanced-dirs": false, + "userscripts-dir": true, + }, + "customization": { + "KDE-sddm2rpm": false, + "KDE-icon-theme": false, + "KDE-templates": false, + "homedir-.hidden": true, + }, + "security": { + "arkenfox": false, + "arkenbird": true, + "fail2ban": false, + "lynis-install": false, + "disable-bluetooth-default": true, + "disable-cups-default": false, + "hardened-kernel": false, + "hardened-malloc": false, } From 33641d6d2cab484d3ce8efa32a4e0ba940b27b2f Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sat, 4 Mar 2023 19:23:06 +0000 Subject: [PATCH 236/240] added more configs, extended some names, reordered thanks for the syntax! --- config/ostree_setup.json | 58 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index bdd6d3f..d0f37f5 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -11,18 +11,66 @@ "fp_kde", "fp_gnome_nightly" ], + "KDE": false, + "disable-gui-software": true, + "rm-firefox-rpm": true, "cdrv-i": true, "wq_ssd-d": true, - "toolbox-r": true, + "toolbox-replace": true, "wayland_ff-e": true, - "ff_rpm-r": true, "ppd-r": true, "deep-sw": true, - "batt_thresh": 80, "bpkgs-r": true, - "fish-s": true, + "fish-setup": true, "fish-mod": { "greetings": null }, - "rfusion-ri": true + "rfusion-ri": true, + "add-fonts": { + "msfonts": true, + "noto-color-emoji": true, + "apple-emoji": false, + }, + "waydroid": { + "waydroid-setup": true, + "waydroid-folders": true, + "waydroid-freeform": true, + }, + "hardware": { + "laptop": true, + "thinkpad": false, + "framework": false, + "tuxedo": false, + "amd": false, + "intel": false, + "nvidia": false, + "intel-mesa": false, + "keyb-backlight": false, + "fprint-sensor": false, + "battery-thresh": 80, + }, + "helperlinks": { + "standard-dirs": true, + "advanced-dirs": false, + "userscripts-dir": true, + }, + "customization": { + "KDE-sddm2rpm": false, + "KDE-icon-theme": false, + "KDE-templates": false, + "homedir-.hidden": true, + }, + "security": { + "arkenfox": false, + "arkenbird": true, + "fail2ban": false, + "lynis-install": false, + "disable-bluetooth-default": true, + "disable-cups-default": false, + "hardened-kernel": false, + "hardened-malloc": false, + }, + "privacy": { + "disable-geoclue": true + }, } From 9a264094dcfe17140f64e6f20d79b19e0ffb12b1 Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sat, 4 Mar 2023 19:36:29 +0000 Subject: [PATCH 237/240] minor changes and descriptions --- config/app_for_install.json | 51 ++++++++++--------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 2856b0e..4ed0ec3 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -99,89 +99,64 @@ "sdesc": "Easily remove all identifying information on Images using exiftool.", "source": "flathub" }, - "exiftool": { - "aid": "exiftool", - "sdesc": "", - "source": "rpm" - }, "perl-Image-ExifTool": { "aid": "perl-Image-ExifTool", - "sdesc": "", + "sdesc": "Remove identifying Data from images.", "source": "rpm" }, "clamtk*": { - "aid": "clamtk*", - "sdesc": "", + "aid": "clamtk", + "sdesc": "Scan Files for Viruses.", "source": "rpm" }, "fail2ban": { "aid": "fail2ban", - "sdesc": "", + "sdesc": "Block brute force attacks when having opened ports on your Machine. Used for Servers worldwide.", "source": "rpm" }, "tlp": { "aid": "tlp", - "sdesc": "", - "source": "rpm" - }, - "make": { - "aid": "make", - "sdesc": "", - "source": "rpm" - }, - "gcc-c++": { - "aid": "gcc-c++", - "sdesc": "", + "sdesc": "Advanced power management for your Laptop.", "source": "rpm" }, "qemu-kvm": { "aid": "qemu-kvm", - "sdesc": "", - "source": "rpm" - }, - "qemu-img": { - "aid": "qemu-img", - "sdesc": "", - "source": "rpm" - }, - "qemu-user-static": { - "aid": "qemu-user-static", - "sdesc": "", + "sdesc": "Requirement for Boxes or Virt-Manager", "source": "rpm" }, "ffmpegthumbs": { "aid": "ffmpegthumbs", - "sdesc": "", + "sdesc": "Enable ffmpeg to be used for video thumbnails.", "source": "rpm" }, "kffmpegthumbnailer": { "aid": "kffmpegthumbnailer", - "sdesc": "", + "sdesc": "Display Video Thumbnails in KDEs File Manager.", "source": "rpm" }, "unrar": { "aid": "unrar", - "sdesc": "", + "sdesc": "Allows unpacking the .rar archive format.", "source": "rpm" }, "stacer": { "aid": "stacer", - "sdesc": "", + "sdesc": "Powerful System monitor, cleaner, startup configurator.", "source": "rpm" }, "python-pip": { "aid": "python-pip", - "sdesc": "", + "sdesc": "Download python scripts from the Python Repository.", "source": "rpm" }, "android-tools": { "aid": "android-tools", - "sdesc": "", + "sdesc": "Includes ADB and Fastboot, needed to install a custom OS on your Android phone.", "source": "rpm" }, "btfs": { "aid": "btfs", - "sdesc": "", + "sdesc": "Mount .torrent files into your system and use them live.", "source": "rpm" } } From 4b759a5ba933c14248157329146abf6e23dfece1 Mon Sep 17 00:00:00 2001 From: trytomakeyouprivate <113100745+trytomakeyouprivate@users.noreply.github.com> Date: Sat, 4 Mar 2023 20:34:56 +0000 Subject: [PATCH 238/240] added apps I layer I dont think recommending Flatpaks makes sense really. --- config/app_for_install.json | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/config/app_for_install.json b/config/app_for_install.json index 2856b0e..20c0ef2 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -183,5 +183,60 @@ "aid": "btfs", "sdesc": "", "source": "rpm" + }, + "cheat": { + "aid": "cheat", + "sdesc": "Command help like man but shorter", + "source": "rpm" + }, + "GNU-Debug": { + "aid": "gdb", + "sdesc": "Debug apps for creating helpful backtraces.", + "source": "rpm" + }, + "Boxes": { + "aid": "gnome-boxes", + "sdesc": "Easy KVM Qemu Virtul Machine management.", + "source": "rpm" + }, + "Virt-Manager": { + "aid": "virt-manager", + "sdesc": "Extended interface for KVM/Qemu, or intermediate users.", + "source": "rpm" + }, + "lm_sensors": { + "aid": "lm_sensors", + "sdesc": "Package to read hardware sensors, dependency for addons.", + "source": "rpm" + }, + "Performance-Measurements": { + "aid": "perf", + "sdesc": "Dependency for the App Hotspot, monitoring and visualizing app performance for debugging or curiosity.", + "source": "rpm" + }, + "Nextcloud-Client": { + "aid": "nextcloud-client", + "sdesc": "Sync your storage with Nextcloud, allows integration in file managers, which is not possible with the Flatpak", + "source": "rpm" + }, + "Pandoc": { + "aid": "pandoc", + "sdesc": "Convert Markdown Documents into HTML, PDF, ODT and LaTex with lots of customization. Dependency of some Dolphin Extensions.", + "source": "rpm" + }, + "RStudio": { + "aid": "R rstudio-desktop", + "sdesc": "Scientific data analysis", + "source": "rpm" + }, + "Waydroid": { + "aid": "waydroid", + "sdesc": "Run Android apps in a container.", + "source": "rpm" + }, + "Powertop": { + "aid": "powertop"", + "sdesc": "Detailed CLI power monitor utility, more features than the GUI displays have.", + "source": "rpm" } } From ec5e63346303abcd9c284007bf99e87fc483c9d0 Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 5 Mar 2023 12:12:20 +0800 Subject: [PATCH 239/240] remove extra quotation --- config/app_for_install.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app_for_install.json b/config/app_for_install.json index 20c0ef2..e4bd351 100644 --- a/config/app_for_install.json +++ b/config/app_for_install.json @@ -235,7 +235,7 @@ "source": "rpm" }, "Powertop": { - "aid": "powertop"", + "aid": "powertop", "sdesc": "Detailed CLI power monitor utility, more features than the GUI displays have.", "source": "rpm" } From 3f18e1c81eb42b013a27071d4d9db1f3fd58ef4a Mon Sep 17 00:00:00 2001 From: James Aaron Erang Date: Sun, 5 Mar 2023 12:16:17 +0800 Subject: [PATCH 240/240] remove kde and improve syntax in align to the previous commit the desktop env can be determined using some modules, hence theres no need to specify whether its kde or gnome replaced `i` with `add`, `r` with `rm`, `ri` with `radd` (reinstall) --- config/ostree_setup.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/config/ostree_setup.json b/config/ostree_setup.json index d0f37f5..2bd8b19 100644 --- a/config/ostree_setup.json +++ b/config/ostree_setup.json @@ -1,7 +1,7 @@ { "afi_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_install.json", "afu_conf": "iaacornus/Fedora-OSTree-Setup/devel/config/app_for_removal.json", - "tprepo-i": [ + "tprepo-add": [ "rpm_rfusion_f", "rpm_rfusion_nf", "rpm_rfusion_tainted", @@ -11,21 +11,20 @@ "fp_kde", "fp_gnome_nightly" ], - "KDE": false, "disable-gui-software": true, "rm-firefox-rpm": true, - "cdrv-i": true, + "cdrv-add": true, "wq_ssd-d": true, "toolbox-replace": true, "wayland_ff-e": true, - "ppd-r": true, + "ppd-rm": true, "deep-sw": true, - "bpkgs-r": true, + "bpkgs-rm": true, "fish-setup": true, "fish-mod": { "greetings": null }, - "rfusion-ri": true, + "rfusion-radd": true, "add-fonts": { "msfonts": true, "noto-color-emoji": true,