diff --git a/slpkg/multi_process.py b/slpkg/multi_process.py index dcdccad1..a88ade49 100644 --- a/slpkg/multi_process.py +++ b/slpkg/multi_process.py @@ -4,10 +4,10 @@ import subprocess from multiprocessing import Process -from slpkg.views.asciibox import AsciiBox from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.progress_bar import ProgressBar +from slpkg.views.asciibox import AsciiBox class MultiProcess(Configs): @@ -28,15 +28,13 @@ class MultiProcess(Configs): def process(self, command: str, filename: str, process_message: str, progress_message: str) -> None: """ Starting multiprocessing install/upgrade process. """ if self.silent_mode and not self.option_for_no_silent: - done: str = f"{'':>1}{self.yellow}Done{self.endc}" + done: str = f'{self.yellow}✔️{self.endc}' self.stderr = subprocess.DEVNULL self.stdout = subprocess.DEVNULL # Starting multiprocessing p1 = Process(target=self.utils.process, args=(command, self.stderr, self.stdout)) - p2 = Process(target=self.progress.progress_bar, args=( - f"{'':>2}{self.bold}{self.ascii.bullet} {progress_message}:", filename) - ) + p2 = Process(target=self.progress.progress_bar, args=(filename, progress_message)) p1.start() p2.start() @@ -47,10 +45,9 @@ class MultiProcess(Configs): # Terminate process 2 if process 1 finished if not p1.is_alive(): if p1.exitcode != 0: - done: str = f'{self.bred}Failed: {self.endc}{process_message}.' - - print(f'{self.endc}{done}', end='') + print(f'{self.bred}Failed: {self.endc}{process_message}.') p2.terminate() + print(f"\r{'':>2}{self.bgreen}{self.ascii.bullet}{self.endc} {filename} {done}{' ' * 17}", end='\r') # Restore the terminal cursor print('\x1b[?25h', self.endc) diff --git a/slpkg/progress_bar.py b/slpkg/progress_bar.py index 9fd1f38b..292510e2 100644 --- a/slpkg/progress_bar.py +++ b/slpkg/progress_bar.py @@ -6,6 +6,7 @@ from progress.spinner import (PixelSpinner, LineSpinner, MoonSpinner, PieSpinner, Spinner) from slpkg.configs import Configs +from slpkg.views.asciibox import AsciiBox class ProgressBar(Configs): @@ -13,11 +14,13 @@ class ProgressBar(Configs): def __init__(self): super(Configs, self).__init__() self.spinner = PixelSpinner + self.ascii = AsciiBox() + self.color: str = self.endc self.spinners: dict = {} self.spinners_color: dict = {} - def progress_bar(self, message: str, filename: str) -> None: + def progress_bar(self, filename: str, message: str) -> None: """ Creating progress bar. """ self.assign_spinners() self.assign_spinner_colors() @@ -25,7 +28,7 @@ class ProgressBar(Configs): self.set_color() if self.spinning_bar: - bar_spinner = self.spinner(f'{self.endc}{message} {filename} {self.color}') + bar_spinner = self.spinner(f"{'':>2}{self.red}{self.ascii.bullet}{self.endc} {filename}: {message}... {self.color}") # print('\033[F', end='', flush=True) try: while True: @@ -34,7 +37,7 @@ class ProgressBar(Configs): except KeyboardInterrupt: raise SystemExit(1) else: - print(f'{message} ', end='', flush=True) + print(f"{'':>2}{self.red}{self.ascii.bullet}{self.endc} {filename}: {message}... {self.color}", end='') def assign_spinners(self) -> None: self.spinners: dict[str] = {