Update for progress bar

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-06-02 20:34:41 +03:00
parent 55c133db74
commit 2f798e8cf2
14 changed files with 60 additions and 93 deletions

View file

@ -8,6 +8,7 @@
- Updated:
* Updated message for invalid package version
* Updated upgrade.log file to json format
* Separation of the process bar with progress bar
### 5.0.9 - 23/05/2024

View file

@ -1,4 +1,4 @@
.TH slpkg 1 "Orestiada, Hellas" "slpkg 5.0.4" dslackw
.TH slpkg 1 "Orestiada, Hellas" "slpkg 5.1.0" dslackw
.SH NOM
.P
slpkg \- Utilitaire de gestion de paquets pour Slackware.
@ -134,7 +134,7 @@ Exemple : '\fIslpkg install python3 --search\fR' ou '\fIslpkg download python3 -
.B -B, --progress-bar
.RS
Appliquez-le pour voir une barre de progression statique au lieu d'un processus exécuté comme la construction,
l'installation ou la suppression.
l'installation ou la suppression. (à utiliser avec : -b, build, -i, install, -U, upgrade, -R --remove)
.RE
.P
.B -p, --pkg-version

View file

@ -1,4 +1,4 @@
.TH slpkg 1 "Orestiada, Hellas" "slpkg 5.0.4" dslackw
.TH slpkg 1 "Orestiada, Hellas" "slpkg 5.1.0" dslackw
.SH NAME
.P
slpkg \- Package manager utility for Slackware.
@ -140,6 +140,7 @@ Example try: '\fIslpkg install python3 --search\fR' or '\fIslpkg download python
.B -B, --progress-bar
.RS
Apply it to see a static progress bar instead of process execute like building, installing or removing.
(to be used with: -b, build, -i, install, -U, upgrade, -R --remove)
.RE
.P
.B -p, --pkg-version

View file

@ -38,12 +38,12 @@ 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.view_process = ViewProcess()
self.check_md5 = Md5sum(flags)
self.download = Downloader(flags)
self.upgrade = Upgrade(repository, data)
self.ascii = AsciiBox()
self.gpg = GPGVerify(flags)
self.gpg = GPGVerify()
self.progress = ProgressBar()
self.dependencies: list = []

View file

@ -17,7 +17,6 @@ class Blacklist(Configs): # pylint: disable=[R0903]
"""Reads and returns the blacklist."""
def __init__(self) -> None:
"""Initilazation class."""
super(Configs, self).__init__()
self.toml_errors = TomlErrors()

View file

@ -41,9 +41,6 @@ class CheckUpdates(Configs): # pylint: disable=[R0902]
self.option_for_check: bool = self.utils.is_option(
('-c', '--check'), flags)
self.option_for_progress_bar: bool = self.utils.is_option(
('-B', '--progress-bar'), flags)
def check_the_repositories(self, queue: str = None) -> None:
"""Save checks to a dictionary.
@ -183,7 +180,6 @@ class CheckUpdates(Configs): # pylint: disable=[R0902]
dict: Description
"""
message: str = 'Checking for news, please wait'
if self.progress_bar_conf or self.option_for_progress_bar:
queue: Queue = Queue()
# Starting multiprocessing
@ -204,10 +200,6 @@ class CheckUpdates(Configs): # pylint: disable=[R0902]
self.error_connected: list = queue.get()
print('\x1b[?25h')
else:
print(f'\r{message}... ', end='')
self.check_the_repositories()
print()
self.check_for_error_connected()
self.view_messages()

View file

@ -32,7 +32,7 @@ class DownloadOnly(Configs): # pylint: disable=[R0902]
self.utils = Utilities()
self.ascii = AsciiBox()
self.errors = Errors()
self.gpg = GPGVerify(flags)
self.gpg = GPGVerify()
self.urls: dict = {}
self.asc_files: list = []

View file

@ -13,11 +13,11 @@ from slpkg.views.view_process import ViewProcess
class GPGVerify(Configs): # pylint: disable=[R0903]
"""GPG verify files."""
def __init__(self, flags: list):
def __init__(self):
super(Configs, self).__init__()
self.ascii = AsciiBox()
self.view = View()
self.view_process = ViewProcess(flags)
self.view_process = ViewProcess()
def verify(self, asc_files: list) -> None:
"""Verify files with gpg tool.

View file

@ -17,13 +17,13 @@ from slpkg.views.view_process import ViewProcess
class InstallData(Configs):
"""Installs data to the repositories path."""
def __init__(self, flags: list):
def __init__(self):
super(Configs, self).__init__()
self.utils = Utilities()
self.repos = Repositories()
self.ascii = AsciiBox()
self.multi_process = MultiProcess()
self.view_process = ViewProcess(flags)
self.view_process = ViewProcess()
def write_repo_info(self, changelog_file: Path, info: dict) -> None:
"""Read the first date of the changelog file.

View file

@ -26,7 +26,7 @@ class LoadData(Configs):
self.utils = Utilities()
self.black = Blacklist()
self.ascii = AsciiBox()
self.view_process = ViewProcess(flags)
self.view_process = ViewProcess()
def load(self, repository: str, message: bool = True) -> dict:
"""Load data to the dictionary.

View file

@ -123,9 +123,7 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_repository,
self.flag_short_repository,
self.flag_parallel,
self.flag_short_parallel,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar,
self.flag_short_parallel
],
'upgrade': [
self.flag_yes,
@ -141,13 +139,11 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_repository,
self.flag_short_repository,
self.flag_parallel,
self.flag_short_parallel,
self.flag_short_parallel
],
'repo-info': [
self.flag_repository,
self.flag_short_repository,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar
self.flag_short_repository
],
'configs': [],
'clean-tmp': [],
@ -200,8 +196,6 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_short_parallel,
self.flag_no_case,
self.flag_short_no_case,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar
],
'remove': [
self.flag_yes,
@ -227,9 +221,7 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_pkg_version,
self.flag_short_pkg_version,
self.flag_no_case,
self.flag_short_no_case,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar
self.flag_short_no_case
],
'search': [
self.flag_search,
@ -239,9 +231,7 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_pkg_version,
self.flag_short_pkg_version,
self.flag_no_case,
self.flag_short_no_case,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar
self.flag_short_no_case
],
'dependees': [
self.flag_full_reverse,
@ -253,9 +243,7 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_pkg_version,
self.flag_short_pkg_version,
self.flag_no_case,
self.flag_short_no_case,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar
self.flag_short_no_case
],
'tracking': [
self.flag_search,
@ -267,9 +255,7 @@ class Menu(Configs): # pylint: disable=[R0902]
self.flag_no_case,
self.flag_short_no_case,
self.flag_resolve_off,
self.flag_short_resolve_off,
self.flag_for_progress_bar,
self.flag_short_for_progress_bar
self.flag_short_resolve_off
]
}

View file

@ -43,11 +43,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.view_process = ViewProcess()
self.check_md5 = Md5sum(flags)
self.download = Downloader(flags)
self.upgrade = Upgrade(repository, data)
self.gpg = GPGVerify(flags)
self.gpg = GPGVerify()
self.errors = Errors()
self.bar_process = None

View file

@ -27,7 +27,7 @@ class UpdateRepositories(Configs): # pylint: disable=[R0902]
self.multi_process = MultiProcess(flags)
self.repos = Repositories()
self.utils = Utilities()
self.data = InstallData(flags)
self.data = InstallData()
self.generate = SBoGenerate()
self.check_updates = CheckUpdates(flags, repository)
self.download = Downloader(flags)

View file

@ -14,7 +14,7 @@ from slpkg.views.asciibox import AsciiBox
class ViewProcess(Configs):
"""View the process messages."""
def __init__(self, flags: list):
def __init__(self):
super(Configs, self).__init__()
self.progress = ProgressBar()
@ -23,35 +23,23 @@ class ViewProcess(Configs):
self.bar_process = None
self.option_for_progress_bar: bool = self.utils.is_option(
('-B', '--progress-bar'), flags)
def message(self, message: str) -> None:
"""Show spinner with message or message."""
if self.progress_bar_conf or self.option_for_progress_bar:
self.bar_process = Process(target=self.progress.progress_bar, args=(message,))
self.bar_process.start()
else:
print(f'\r{message}... ', end='')
def done(self) -> None:
"""Show 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(f'\b{self.bgreen}{self.ascii.done}{self.endc}', end='')
print('\x1b[?25h') # Reset cursor after hiding.
else:
print(f'{self.bgreen}{self.ascii.done}{self.endc}')
def failed(self) -> None:
"""Show for failed 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(f'\b{self.bred}{self.ascii.failed}{self.endc}', end='')
print('\x1b[?25h') # Reset cursor after hiding.
else:
print(f'{self.bred}{self.ascii.failed}{self.endc}')