mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Updated for gpg verify
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
b66a32afba
commit
90f3cea360
1 changed files with 15 additions and 14 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue