diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py index ded634ce..dfc60714 100644 --- a/slpkg/binaries/install.py +++ b/slpkg/binaries/install.py @@ -46,7 +46,7 @@ class Packages(Configs): # pylint: disable=[R0902] self.download = Downloader(flags) self.upgrade = Upgrade(repository, data) self.ascii = AsciiBox() - self.gpg = GPGVerify() + self.gpg = GPGVerify(flags) self.progress = ProgressBar() self.dependencies: list = [] diff --git a/slpkg/gpg_verify.py b/slpkg/gpg_verify.py index aec6a564..0de809d5 100644 --- a/slpkg/gpg_verify.py +++ b/slpkg/gpg_verify.py @@ -7,6 +7,7 @@ import subprocess from slpkg.configs import Configs from slpkg.views.asciibox import AsciiBox from slpkg.views.views import View +from slpkg.views.view_process import ViewProcess class GPGVerify(Configs): # pylint: disable=[R0903] @@ -14,10 +15,11 @@ class GPGVerify(Configs): # pylint: disable=[R0903] """ GPG verify files. """ - def __init__(self): + def __init__(self, flags: list): super(Configs, self).__init__() self.ascii = AsciiBox() self.view = View() + self.view_process = ViewProcess(flags) def verify(self, asc_files: list) -> None: """ Verify files with gpg tool. @@ -28,12 +30,12 @@ class GPGVerify(Configs): # pylint: disable=[R0903] if self.gpg_verification: output: dict = {} gpg_command: str = 'gpg --verify' - print('\rVerify files with GPG... ', end='') + self.view_process.message('Verify files with GPG') # exit_code: int = 0 for file in asc_files: - with subprocess.Popen(f'{gpg_command} {file}', shell=True, stdout=subprocess.PIPE, + with subprocess.Popen(f'{gpg_command} {file}a', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) as process: process.wait() @@ -42,10 +44,10 @@ class GPGVerify(Configs): # pylint: disable=[R0903] all_zero = all(value == 0 for value in output.values()) if all_zero: - print(f'{self.bgreen}{self.ascii.done}{self.endc}') + self.view_process.done() else: - print(f'{self.bred}{self.ascii.failed}{self.endc}') + self.view_process.failed() for file, code in output.items(): if code != 0: - print(f"{'':>2}Error {code}: {file}") + print(f"{'':>2}{self.red}Error{self.endc} {code}: {file}") self.view.question() diff --git a/slpkg/sbos/slackbuild.py b/slpkg/sbos/slackbuild.py index 5d33a723..2b9c4579 100644 --- a/slpkg/sbos/slackbuild.py +++ b/slpkg/sbos/slackbuild.py @@ -50,7 +50,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904] self.check_md5 = Md5sum(flags) self.download = Downloader(flags) self.upgrade = Upgrade(repository, data) - self.gpg = GPGVerify() + self.gpg = GPGVerify(flags) self.errors = Errors() self.bar_process = None diff --git a/slpkg/views/view_process.py b/slpkg/views/view_process.py index 52d68ae3..ff106b4f 100644 --- a/slpkg/views/view_process.py +++ b/slpkg/views/view_process.py @@ -48,3 +48,14 @@ class ViewProcess(Configs): print('\x1b[?25h') 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('\x1b[?25h') + else: + print(f'{self.bred}{self.ascii.failed}{self.endc}')