Updated for process message

This commit is contained in:
Dimitris Zlatanidis 2024-05-03 17:30:12 +03:00
parent 3e7614e2fa
commit ca99107938

View file

@ -9,7 +9,6 @@ import shutil
from pathlib import Path
from collections import OrderedDict
from multiprocessing import Process
from slpkg.upgrade import Upgrade
from slpkg.checksum import Md5sum
@ -21,9 +20,9 @@ from slpkg.gpg_verify import GPGVerify
from slpkg.error_messages import Errors
from slpkg.downloader import Downloader
from slpkg.views.asciibox import AsciiBox
from slpkg.progress_bar import ProgressBar
from slpkg.repositories import Repositories
from slpkg.multi_process import MultiProcess
from slpkg.views.view_process import ViewProcess
from slpkg.sbos.dependencies import resolve_requires
@ -47,11 +46,11 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
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)
self.gpg = GPGVerify()
self.progress = ProgressBar()
self.errors = Errors()
self.bar_process = None
@ -68,9 +67,6 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
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.slackbuilds: list = self.utils.apply_package_pattern(data, slackbuilds)
self.repo_tag: str = self.repos.repositories[repository]['repo_tag']
@ -79,7 +75,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
def execute(self) -> None:
""" Calls the 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()
@ -354,32 +350,11 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
[(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 for 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()