Updated for process message

This commit is contained in:
Dimitris Zlatanidis 2024-05-03 23:10:43 +03:00
parent ca99107938
commit fd0f0917ab

View file

@ -7,7 +7,6 @@ import time
import json
from pathlib import Path
from collections import OrderedDict
from multiprocessing import Process
from slpkg.upgrade import Upgrade
from slpkg.configs import Configs
@ -21,6 +20,7 @@ from slpkg.views.asciibox import AsciiBox
from slpkg.progress_bar import ProgressBar
from slpkg.multi_process import MultiProcess
from slpkg.binaries.required import Required
from slpkg.views.view_process import ViewProcess
class Packages(Configs): # pylint: disable=[R0902]
@ -41,6 +41,7 @@ class Packages(Configs): # pylint: disable=[R0902]
self.dialogbox = DialogBox()
self.multi_proc = MultiProcess(flags)
self.view = View(flags, repository, data)
self.view_process = ViewProcess(flags)
self.check_md5 = Md5sum(flags)
self.download = Downloader(flags)
self.upgrade = Upgrade(repository, data)
@ -61,15 +62,12 @@ class Packages(Configs): # pylint: disable=[R0902]
self.option_for_skip_installed: bool = self.utils.is_option(
('-k', '--skip-installed'), flags)
self.option_for_progress_bar: bool = self.utils.is_option(
('-B', '--progress-bar'), flags)
self.packages: list = self.utils.apply_package_pattern(data, packages)
def execute(self) -> None:
""" Calls methods in order.
"""
self.progress_bar_message()
self.view_process.message('Resolving dependencies')
self.creating_dependencies_list()
self.choose_package_dependencies()
self.add_dependencies_to_install_order()
@ -251,32 +249,11 @@ class Packages(Configs): # pylint: disable=[R0902]
choices.extend([(package, repo_ver, status, help_text)])
self.done_process()
self.view_process.done()
text: str = f'There are {len(choices)} dependencies:'
code, self.dependencies = self.dialogbox.checklist(text, title, height, width, list_height, choices) # pylint: disable=[W0612]
os.system('clear')
else:
self.done_process()
def progress_bar_message(self) -> None:
""" Prints the progress message.
"""
if self.progress_bar_conf or self.option_for_progress_bar:
message: str = 'Resolving dependencies'
self.bar_process = Process(target=self.progress.progress_bar, args=(message,))
self.bar_process.start()
else:
print('\rResolving dependencies... ', end='')
def done_process(self) -> None:
""" Prints the done message.
"""
if self.progress_bar_conf or self.option_for_progress_bar:
time.sleep(0.1)
self.bar_process.terminate()
self.bar_process.join()
print('\x1b[?25h')
else:
print(f'{self.bgreen}{self.ascii.done}{self.endc}')
self.view_process.done()