Updated to delete line

This commit is contained in:
Dimitris Zlatanidis 2024-04-03 18:38:47 +03:00
parent 729f57c9c8
commit 06e686f81b

View file

@ -1,15 +1,16 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import shutil
import subprocess import subprocess
from datetime import datetime from datetime import datetime
from multiprocessing import Process from multiprocessing import Process
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.error_messages import Errors
from slpkg.views.asciibox import AsciiBox from slpkg.views.asciibox import AsciiBox
from slpkg.progress_bar import ProgressBar from slpkg.progress_bar import ProgressBar
from slpkg.error_messages import Errors
class MultiProcess(Configs): class MultiProcess(Configs):
@ -22,6 +23,7 @@ class MultiProcess(Configs):
self.ascii = AsciiBox() self.ascii = AsciiBox()
self.errors = Errors() self.errors = Errors()
self.columns, self.rows = shutil.get_terminal_size()
self.timestamp: str = datetime.now().strftime("%Y-%m-%d %H:%M:%S") self.timestamp: str = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.head_message: str = f'Timestamp: {self.timestamp}' self.head_message: str = f'Timestamp: {self.timestamp}'
self.bottom_message: str = 'EOF - End of log file' self.bottom_message: str = 'EOF - End of log file'
@ -67,12 +69,13 @@ class MultiProcess(Configs):
# Terminate process 2 if process 1 finished # Terminate process 2 if process 1 finished
if not process_1.is_alive(): if not process_1.is_alive():
process_2.terminate() process_2.terminate()
print(f"\r{' ' * (self.columns - 1)}", end='') # Delete previous line.
if process_1.exitcode != 0: if process_1.exitcode != 0:
print(f"\r{'':>2}{self.bred}{self.ascii.bullet}{self.endc} {filename} {failed}{' ' * 17}", end='') print(f"\r{'':>2}{self.bred}{self.ascii.bullet}{self.endc} {filename} {failed}", end='')
elif installed: elif installed:
print(f"\r{'':>2}{self.bred}{self.ascii.bullet}{self.endc} {filename} {skip}{' ' * 17}", end='') print(f"\r{'':>2}{self.bred}{self.ascii.bullet}{self.endc} {filename} {skip}", end='')
else: else:
print(f"\r{'':>2}{self.bgreen}{self.ascii.bullet}{self.endc} {filename} {done}{' ' * 17}", end='') print(f"\r{'':>2}{self.bgreen}{self.ascii.bullet}{self.endc} {filename} {done}", end='')
# Restore the terminal cursor # Restore the terminal cursor
print('\x1b[?25h', self.endc) print('\x1b[?25h', self.endc)