mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 00:03:42 +05:00
feat(kiauh): add helper methods to check for installed packages
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -10,7 +10,11 @@
|
||||
# ======================================================================= #
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Dict, Literal
|
||||
from typing import Dict, Literal, List
|
||||
|
||||
from kiauh.utils.constants import COLOR_CYAN, RESET_FORMAT
|
||||
from kiauh.utils.logger import Logger
|
||||
from kiauh.utils.system_utils import check_package_install, install_system_packages
|
||||
|
||||
|
||||
def get_current_date() -> Dict[Literal["date", "time"], str]:
|
||||
@@ -23,3 +27,19 @@ def get_current_date() -> Dict[Literal["date", "time"], str]:
|
||||
time: str = now.strftime("%H-%M-%S")
|
||||
|
||||
return {"date": date, "time": time}
|
||||
|
||||
|
||||
def check_install_dependencies(deps: List[str]) -> None:
|
||||
"""
|
||||
Common helper method to check if dependencies are installed
|
||||
and if not, install them automatically |
|
||||
:param deps: List of strings of package names to check if installed
|
||||
:return: None
|
||||
"""
|
||||
requirements = check_package_install(deps)
|
||||
if requirements:
|
||||
Logger.print_status("Installing dependencies ...")
|
||||
Logger.print_info("The following packages need installation:")
|
||||
for _ in requirements:
|
||||
print(f"{COLOR_CYAN}● {_}{RESET_FORMAT}")
|
||||
install_system_packages(requirements)
|
||||
|
||||
Reference in New Issue
Block a user