mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-19 10:27:07 +01:00
Updated for progress bar
This commit is contained in:
parent
bb90ab841b
commit
368d9cae89
4 changed files with 38 additions and 21 deletions
|
@ -143,7 +143,7 @@ class CheckUpdates(Configs):
|
|||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.check_for_updates)
|
||||
p2 = Process(target=self.progress.bar, args=(message, ''))
|
||||
p2 = Process(target=self.progress.progress_bar, args=(message, ''))
|
||||
|
||||
p1.start()
|
||||
p2.start()
|
||||
|
|
|
@ -32,7 +32,7 @@ class MultiProcess(Configs):
|
|||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.utils.process, args=(command, self.stderr, self.stdout))
|
||||
p2 = Process(target=self.progress.bar, args=(f'{progress_message}:', filename))
|
||||
p2 = Process(target=self.progress.progress_bar, args=(f'{progress_message}:', filename))
|
||||
|
||||
p1.start()
|
||||
p2.start()
|
||||
|
|
|
@ -12,17 +12,41 @@ class ProgressBar(Configs):
|
|||
|
||||
def __init__(self):
|
||||
super(Configs, self).__init__()
|
||||
self.spinner = PixelSpinner
|
||||
self.color: str = self.endc
|
||||
self.spinners: dict = {}
|
||||
self.spinners_color: dict = {}
|
||||
|
||||
def bar(self, message: str, filename: str) -> None:
|
||||
def progress_bar(self, message: str, filename: str) -> None:
|
||||
""" Creating progress bar. """
|
||||
spinners: dict = {
|
||||
self.assign_spinners()
|
||||
self.assign_spinner_colors()
|
||||
self.set_spinner()
|
||||
self.set_color()
|
||||
|
||||
if self.spinning_bar:
|
||||
bar_spinner = self.spinner(f'{self.endc}{message} {filename} {self.color}')
|
||||
# print('\033[F', end='', flush=True)
|
||||
try:
|
||||
while True:
|
||||
time.sleep(0.1)
|
||||
bar_spinner.next()
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
print(f'{message} ', end='', flush=True)
|
||||
|
||||
def assign_spinners(self):
|
||||
self.spinners: dict = {
|
||||
'pixel': PixelSpinner,
|
||||
'line': LineSpinner,
|
||||
'moon': MoonSpinner,
|
||||
'pie': PieSpinner,
|
||||
'spinner': Spinner
|
||||
}
|
||||
colors: dict = {
|
||||
|
||||
def assign_spinner_colors(self):
|
||||
self.spinners_color: dict = {
|
||||
'green': self.green,
|
||||
'violet': self.violet,
|
||||
'yellow': self.yellow,
|
||||
|
@ -33,21 +57,14 @@ class ProgressBar(Configs):
|
|||
'': self.endc
|
||||
}
|
||||
|
||||
def set_spinner(self):
|
||||
try:
|
||||
spinner = spinners[self.progress_spinner]
|
||||
color: str = colors[self.spinner_color]
|
||||
self.spinner = self.spinners[self.progress_spinner]
|
||||
except KeyError:
|
||||
spinner = PixelSpinner
|
||||
color: str = self.endc
|
||||
self.spinner = PixelSpinner
|
||||
|
||||
if self.spinning_bar:
|
||||
bar_spinner = spinner(f'{self.endc}{message} {filename} {color}')
|
||||
# print('\033[F', end='', flush=True)
|
||||
try:
|
||||
while True:
|
||||
time.sleep(0.1)
|
||||
bar_spinner.next()
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit(1)
|
||||
else:
|
||||
print(f'{message} ', end='', flush=True)
|
||||
def set_color(self):
|
||||
try:
|
||||
self.color: str = self.spinners_color[self.spinner_color]
|
||||
except KeyError:
|
||||
self.color: str = self.endc
|
||||
|
|
|
@ -616,7 +616,7 @@ class UpdateRepository(Configs):
|
|||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.check_for_updates, args=(queue,))
|
||||
p2 = Process(target=self.progress.bar, args=(message, ''))
|
||||
p2 = Process(target=self.progress.progress_bar, args=(message, ''))
|
||||
|
||||
p1.start()
|
||||
p2.start()
|
||||
|
|
Loading…
Reference in a new issue