Updated fro dialogbox

This commit is contained in:
Dimitris Zlatanidis 2023-03-28 13:15:53 +03:00
parent c2062cbe39
commit 619a4e09f2
2 changed files with 56 additions and 11 deletions

View file

@ -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

View file

@ -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])