Added config for spinning bar

This commit is contained in:
Dimitris Zlatanidis 2023-04-25 20:12:16 +03:00
parent b19b046947
commit 5be574ed2e
5 changed files with 26 additions and 11 deletions

View file

@ -1,3 +1,7 @@
4.8.2 - 25/04/2023
Added:
- Disable or enable the spinning bar
4.8.1 - 21/04/2023
Updated:
- For error messages

View file

@ -44,6 +44,9 @@ PARALLEL_DOWNLOADS = false
# add '*_SBo' pattern. Default is the '*'.
FILE_PATTERN = "*"
# Enable or disable the spinning bar. Default is true. [true/false]
SPINNING_BAR = true
# There are 5 predefined spinners for the progress bar.
# Default is pixel. [spinner/pie/moon/line/pixel]
PROGRESS_SPINNER = "pixel"

View file

@ -44,6 +44,7 @@ class Configs:
ask_question: bool = True
parallel_downloads: bool = False
file_pattern: str = '*'
spinning_bar: str = True
progress_spinner: str = 'pixel'
spinner_color: str = 'green'
@ -79,6 +80,7 @@ class Configs:
file_list_suffix: str = config['FILE_LIST_SUFFIX']
parallel_downloads: bool = config['PARALLEL_DOWNLOADS']
file_pattern_conf: str = config['FILE_PATTERN']
spinning_bar: str = config['SPINNING_BAR']
progress_spinner: str = config['PROGRESS_SPINNER']
spinner_color: str = config['SPINNER_COLOR']
proxy_address: str = config['PROXY_ADDRESS']

View file

@ -75,7 +75,8 @@ class FormConfigs(Configs):
'SILENT_MODE',
'ASCII_CHARACTERS',
'ASK_QUESTION',
'PARALLEL_DOWNLOADS'
'PARALLEL_DOWNLOADS',
'SPINNING_BAR'
]
values: list = ['true', 'false']
@ -110,11 +111,13 @@ class FormConfigs(Configs):
if line.lstrip().startswith(
('COLORS =', 'DIALOG =',
('COLORS =',
'DIALOG =',
'SILENT_MODE =',
'ASCII_CHARACTERS =',
'ASK_QUESTION =',
'PARALLEL_DOWNLOADS =')
'PARALLEL_DOWNLOADS =',
'SPINNING_BAR =')
):
line: str = line.replace('"', '')

View file

@ -40,11 +40,14 @@ class ProgressBar(Configs):
spinner = PixelSpinner
color: str = self.endc
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)
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)