Updated for gpg verify

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-05-06 12:05:58 +03:00
parent b66a32afba
commit 90f3cea360

View file

@ -11,7 +11,7 @@ from slpkg.views.views import View
class GPGVerify(Configs): # pylint: disable=[R0903] class GPGVerify(Configs): # pylint: disable=[R0903]
""" GPG verify key. """ GPG verify files.
""" """
def __init__(self): def __init__(self):
@ -26,25 +26,26 @@ class GPGVerify(Configs): # pylint: disable=[R0903]
asc_files (list): List of files. asc_files (list): List of files.
""" """
if self.gpg_verification: if self.gpg_verification:
verify_message: str = '\rVerify files with GPG... ' output: dict = {}
gpg_command: str = 'gpg --verify' gpg_command: str = 'gpg --verify'
print(verify_message, end='') print('\rVerify files with GPG... ', end='')
exit_code: int = 0 # exit_code: int = 0
for i, file in enumerate(asc_files): for file in asc_files:
with subprocess.Popen(f'{gpg_command} {file}', shell=True, stdout=subprocess.PIPE, with subprocess.Popen(f'{gpg_command} {file}', shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, text=True) as process: stderr=subprocess.STDOUT, text=True) as process:
process.wait() process.wait()
if process.returncode != 0: output[file.name] = process.returncode
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}")
if exit_code == 0: all_zero = all(value == 0 for value in output.values())
print(f'{self.bgreen}{self.ascii.done}{self.endc}') if all_zero:
elif exit_code != 0 and self.dialog: print(f'{self.bgreen}{self.ascii.done}{self.endc}')
self.view.question() 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()