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 4.8.1 - 21/04/2023
Updated: Updated:
- For error messages - For error messages

View file

@ -44,6 +44,9 @@ PARALLEL_DOWNLOADS = false
# add '*_SBo' pattern. Default is the '*'. # add '*_SBo' pattern. Default is the '*'.
FILE_PATTERN = "*" 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. # There are 5 predefined spinners for the progress bar.
# Default is pixel. [spinner/pie/moon/line/pixel] # Default is pixel. [spinner/pie/moon/line/pixel]
PROGRESS_SPINNER = "pixel" PROGRESS_SPINNER = "pixel"

View file

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

View file

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

View file

@ -40,11 +40,14 @@ class ProgressBar(Configs):
spinner = PixelSpinner spinner = PixelSpinner
color: str = self.endc color: str = self.endc
bar_spinner = spinner(f'{self.endc}{message} {filename} {color}') if self.spinning_bar:
# print('\033[F', end='', flush=True) bar_spinner = spinner(f'{self.endc}{message} {filename} {color}')
try: # print('\033[F', end='', flush=True)
while True: try:
time.sleep(0.1) while True:
bar_spinner.next() time.sleep(0.1)
except KeyboardInterrupt: bar_spinner.next()
raise SystemExit(1) except KeyboardInterrupt:
raise SystemExit(1)
else:
print(f'{message} ', end='', flush=True)