Updated for process messages

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-05-06 12:22:08 +03:00
parent 90f3cea360
commit e922c36e00
4 changed files with 21 additions and 8 deletions

View file

@ -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 = []

View file

@ -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()

View file

@ -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

View file

@ -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}')