From 619a4e09f282cf1d9b02d905203ced72ac546d03 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 28 Mar 2023 13:15:53 +0300 Subject: [PATCH] Updated fro dialogbox --- slpkg/binaries/install.py | 49 +++++++++++++++++++++++++++++++++++++-- slpkg/install_data.py | 18 +++++++------- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index 42ee20b6..0bddcb3f 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +import os import time import subprocess from multiprocessing import Process @@ -8,6 +9,7 @@ from multiprocessing import Process from slpkg.configs import Configs from slpkg.checksum import Md5sum from slpkg.utilities import Utilities +from slpkg.dialog_box import DialogBox from slpkg.downloader import Downloader from slpkg.views.views import ViewMessage from slpkg.progress_bar import ProgressBar @@ -29,6 +31,7 @@ class Packages(Configs): self.color = self.colour() self.utils = Utilities() self.repos = Repositories() + self.dialogbox = DialogBox() self.view_message = ViewMessage(self.flags) self.output: int = 0 @@ -53,7 +56,8 @@ class Packages(Configs): def execute(self) -> None: self.dependencies() - self.view_message.install_packages(self.packages, self.mode, self.packages_requires, repo=self.repo) + + self.view_message.install_packages(self.packages, self.mode, self.packages_requires, self.repo) self.view_message.question() start: float = time.time() @@ -75,7 +79,8 @@ class Packages(Configs): if req not in self.packages: requires.append(req) - self.packages_requires = requires + self.packages_requires = self.choose_dependencies(requires) + self.install_order = self.packages_requires + self.packages def download(self) -> None: @@ -169,3 +174,43 @@ class Packages(Configs): """ Stop the process and print the error message. """ if self.output != 0: self.utils.raise_error_message(f"{self.output}: {self.process_message}") + + def choose_dependencies(self, dependencies: list) -> list: + """ Choose packages for install. """ + height: int = 10 + width: int = 70 + list_height: int = 0 + choices: list = [] + title: str = ' Choose dependencies you want to install ' + + for package in dependencies: + status: bool = False + + repo_ver: str = BinQueries(package, self.repo).version() + help_text: str = f'Package: {package}-{repo_ver}' + + if self.mode == 'build': + status: bool = True + + if self.mode == 'upgrade' and self.utils.is_package_upgradeable(package): + status: bool = True + + if self.mode == 'install' and not self.utils.is_package_installed(package): + status: bool = True + + if self.mode == 'install' and self.utils.is_package_upgradeable(package): + status: bool = True + + choices += [(package, repo_ver, status, help_text)] + + text: str = f'There are {len(choices)} dependencies:' + + code, tags = self.dialogbox.checklist(text, dependencies, title, height, + width, list_height, choices) + + if not code: + return dependencies + + os.system('clear') + + return tags diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 2e417ef5..3e2f83ae 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -99,9 +99,9 @@ class CreateData(Configs): if line.startswith(pkg_tag[0]): package_name = line.replace(pkg_tag[0], '').strip() - spit_package: list = self.utils.split_binary_pkg(package_name) - cache.append(spit_package[0]) # package name - cache.append(spit_package[1]) # package version + split_package: list = self.utils.split_binary_pkg(package_name) + cache.append(split_package[0]) # package name + cache.append(split_package[1]) # package version cache.append(package_name) cache.append(self.repos.alien_repo_mirror) try: @@ -185,9 +185,9 @@ class CreateData(Configs): if line.startswith(pkg_tag[0]): package_name = line.replace(pkg_tag[0], '').strip() - spit_package: list = self.utils.split_binary_pkg(package_name) - cache.append(spit_package[0]) # package name - cache.append(spit_package[1]) # package version + split_package: list = self.utils.split_binary_pkg(package_name) + cache.append(split_package[0]) # package name + cache.append(split_package[1]) # package version cache.append(package_name) try: cache.append(checksums_dict[package_name]) @@ -271,9 +271,9 @@ class CreateData(Configs): if line.startswith(pkg_tag[0]): package_name: str = line.replace(pkg_tag[0], '').strip() - spit_package: list = self.utils.split_binary_pkg(package_name) - cache.append(spit_package[0]) # package name - cache.append(spit_package[1]) # package version + split_package: list = self.utils.split_binary_pkg(package_name) + cache.append(split_package[0]) # package name + cache.append(split_package[1]) # package version cache.append(package_name) try: cache.append(checksums_dict[package_name])