From 2f798e8cf20b3a91de0b719a49ad29505ff76796 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 2 Jun 2024 20:34:41 +0300 Subject: [PATCH] Update for progress bar Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 1 + man/slpkg-fr.1 | 24 +++++++++++------------ man/slpkg.1 | 3 ++- slpkg/binaries/install.py | 4 ++-- slpkg/blacklist.py | 1 - slpkg/check_updates.py | 36 +++++++++++++--------------------- slpkg/download_only.py | 2 +- slpkg/gpg_verify.py | 4 ++-- slpkg/install_data.py | 4 ++-- slpkg/load_data.py | 2 +- slpkg/main.py | 28 +++++++------------------- slpkg/sbos/slackbuild.py | 4 ++-- slpkg/update_repositories.py | 2 +- slpkg/views/view_process.py | 38 ++++++++++++------------------------ 14 files changed, 60 insertions(+), 93 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7710cccc..8fa42551 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 diff --git a/man/slpkg-fr.1 b/man/slpkg-fr.1 index 716bd5b8..a02f1888 100644 --- a/man/slpkg-fr.1 +++ b/man/slpkg-fr.1 @@ -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. @@ -14,12 +14,12 @@ slpkg [-h|-v] [-u, update] [-U, upgrade] [-I, repo-info] -P, --parallel, -o, --repository=\fINAME\fR, -z, --directory=\fIPATH\fR .SH DESCRIPTION .P -Slpkg est un gestionnaire de paquets qui installe, met à jour et supprime les paquets sur les systèmes basés sur Slackware. -Il calcule automatiquement les dépendances et détermine ce qui doit se passer pour installer les paquets. -Slpkg facilite la maintenance de groupes de machines sans avoir à les mettre à jour manuellement. +Slpkg est un gestionnaire de paquets qui installe, met à jour et supprime les paquets sur les systèmes basés sur Slackware. +Il calcule automatiquement les dépendances et détermine ce qui doit se passer pour installer les paquets. +Slpkg facilite la maintenance de groupes de machines sans avoir à les mettre à jour manuellement. .P -Slpkg travaille en accord avec les standards de l'organisation SlackBuilds.org pour construire des paquets. -Il utilise également les instructions de Slackware Linux pour l'installation, la mise à jour ou la suppression des paquets. +Slpkg travaille en accord avec les standards de l'organisation SlackBuilds.org pour construire des paquets. +Il utilise également les instructions de Slackware Linux pour l'installation, la mise à jour ou la suppression des paquets. .SH COMMANDES .P .B -u, update @@ -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 @@ -187,10 +187,10 @@ En dehors de la manière classique, vous pouvez mettre plusieurs options qui ne .RE .SH FILELIST|PACKAGES .P -Au lieu de paquets, vous pouvez transmettre un fichier texte avec le suffixe '.pkgs' et les noms des paquets. -Exemple : '\fIslpkg install list.pkgs\fR'. -Editez le fichier de configuration '/etc/slpkg/slpkg.toml' pour changer le suffixe si vous le souhaitez. -Vous pouvez utiliser des listes provenant d'autres sources, comme les fichiers '.sqf'. +Au lieu de paquets, vous pouvez transmettre un fichier texte avec le suffixe '.pkgs' et les noms des paquets. +Exemple : '\fIslpkg install list.pkgs\fR'. +Editez le fichier de configuration '/etc/slpkg/slpkg.toml' pour changer le suffixe si vous le souhaitez. +Vous pouvez utiliser des listes provenant d'autres sources, comme les fichiers '.sqf'. .RE .SH A SAVOIR .P @@ -198,7 +198,7 @@ Il y a cinq indicateurs lorsque certaines commandes sont utilisées, par exemple Cyan : Installer, Jaune : Construire, Gris : Installé, Violet : Installé Pour construire, Gris : C'est installé, Violet : Pour la mise à jour, Rouge : Pour supprimer. -Lorsque vous utilisez les commandes install, build, upgrade ou remove, vous devez savoir que si le paquet est installé, sa couleur passera au gris, +Lorsque vous utilisez les commandes install, build, upgrade ou remove, vous devez savoir que si le paquet est installé, sa couleur passera au gris, si le paquet peut être mis à jour, il devient violet, et s'il n'est pas installé, sa couleur est cyan. De même, si vous essayez de supprimer un paquet, la couleur du paquet devient rouge. diff --git a/man/slpkg.1 b/man/slpkg.1 index a93c6aae..32f8f35e 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -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 diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index a4e7e715..3b958f5a 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -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 = [] diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 620220e8..13419e4e 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -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() diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 9d7e7661..c5dc40de 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -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,31 +180,26 @@ 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() + queue: Queue = Queue() - # Starting multiprocessing - process_1 = Process(target=self.check_the_repositories, args=(queue,)) - process_2 = Process(target=self.progress.progress_bar, args=(message,)) + # Starting multiprocessing + process_1 = Process(target=self.check_the_repositories, args=(queue,)) + process_2 = Process(target=self.progress.progress_bar, args=(message,)) - process_1.start() - process_2.start() + process_1.start() + process_2.start() - # Wait until process 1 finish - process_1.join() + # Wait until process 1 finish + process_1.join() - # Terminate process 2 if process 1 finished - if not process_1.is_alive(): - process_2.terminate() + # Terminate process 2 if process 1 finished + if not process_1.is_alive(): + process_2.terminate() - self.compare: dict = queue.get() - self.error_connected: list = queue.get() + self.compare: dict = queue.get() + self.error_connected: list = queue.get() - print('\x1b[?25h') - else: - print(f'\r{message}... ', end='') - self.check_the_repositories() - print() + print('\x1b[?25h') self.check_for_error_connected() self.view_messages() diff --git a/slpkg/download_only.py b/slpkg/download_only.py index d8f0d40f..2d96f210 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -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 = [] diff --git a/slpkg/gpg_verify.py b/slpkg/gpg_verify.py index 9eba738c..963b8246 100644 --- a/slpkg/gpg_verify.py +++ b/slpkg/gpg_verify.py @@ -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. diff --git a/slpkg/install_data.py b/slpkg/install_data.py index e133bd20..52a3b232 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -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. diff --git a/slpkg/load_data.py b/slpkg/load_data.py index d9392b94..8ed3b892 100644 --- a/slpkg/load_data.py +++ b/slpkg/load_data.py @@ -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. diff --git a/slpkg/main.py b/slpkg/main.py index e710f882..9986d67d 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -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 ] } diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 0685bf91..5340d3ae 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -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 diff --git a/slpkg/update_repositories.py b/slpkg/update_repositories.py index 8370ec8b..d45782ac 100644 --- a/slpkg/update_repositories.py +++ b/slpkg/update_repositories.py @@ -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) diff --git a/slpkg/views/view_process.py b/slpkg/views/view_process.py index 91d14582..cd33854a 100644 --- a/slpkg/views/view_process.py +++ b/slpkg/views/view_process.py @@ -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='') + self.bar_process = Process(target=self.progress.progress_bar, args=(message,)) + self.bar_process.start() 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}') + 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. 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}') + 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.