From 90f3cea360be3ad20b23e67c705f3aa64d096791 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 6 May 2024 12:05:58 +0300 Subject: [PATCH] Updated for gpg verify Signed-off-by: Dimitris Zlatanidis --- slpkg/gpg_verify.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/slpkg/gpg_verify.py b/slpkg/gpg_verify.py index 1ef1e795..aec6a564 100644 --- a/slpkg/gpg_verify.py +++ b/slpkg/gpg_verify.py @@ -11,7 +11,7 @@ from slpkg.views.views import View class GPGVerify(Configs): # pylint: disable=[R0903] - """ GPG verify key. + """ GPG verify files. """ def __init__(self): @@ -26,25 +26,26 @@ class GPGVerify(Configs): # pylint: disable=[R0903] asc_files (list): List of files. """ if self.gpg_verification: - verify_message: str = '\rVerify files with GPG... ' + output: dict = {} gpg_command: str = 'gpg --verify' - print(verify_message, end='') + print('\rVerify files with GPG... ', end='') - exit_code: int = 0 - for i, file in enumerate(asc_files): + # exit_code: int = 0 + for file in asc_files: with subprocess.Popen(f'{gpg_command} {file}', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) as process: process.wait() - if process.returncode != 0: - exit_code: int = process.returncode - if i == 0: - print(f'{self.bred}{self.ascii.failed}{self.endc}') - print(f"{'':>2}Error {process.returncode}: {file.name}") + output[file.name] = process.returncode - if exit_code == 0: - print(f'{self.bgreen}{self.ascii.done}{self.endc}') - elif exit_code != 0 and self.dialog: - self.view.question() + all_zero = all(value == 0 for value in output.values()) + if all_zero: + print(f'{self.bgreen}{self.ascii.done}{self.endc}') + else: + print(f'{self.bred}{self.ascii.failed}{self.endc}') + for file, code in output.items(): + if code != 0: + print(f"{'':>2}Error {code}: {file}") + self.view.question()