Added parallel to the configs

This commit is contained in:
Dimitris Zlatanidis 2023-03-13 10:35:08 +02:00
parent 2f0b136954
commit 531d9e8b66
4 changed files with 22 additions and 8 deletions

View file

@ -28,6 +28,8 @@
# Set false to all the questions. If set false option --yes will not work.
# Default is true. [true/false].
ASK_QUESTION = true
# Download parallel multi-sources. Default is true. [true/false].
PARALLEL_DOWNLOADS = true
# Pass your file pattern here, instead, you can use '--file-pattern=' option.
FILE_PATTERN = ""

View file

@ -119,6 +119,9 @@ class Configs:
# Set false to all the questions.
ask_question: bool = True
# Download parallel multi-sources.
parallel_downloads: bool = True
# Pass the file pattern here.
file_pattern_conf: str = ""
@ -194,6 +197,9 @@ class Configs:
# File suffix for list packages.
file_list_suffix: str = config['FILE_LIST_SUFFIX']
# Download parallel multi-sources.
parallel_downloads: bool = config['PARALLEL_DOWNLOADS']
# Pass the file pattern here.
file_pattern_conf: str = config['FILE_PATTERN']

View file

@ -33,13 +33,17 @@ class Downloader(Configs, Utilities):
""" Starting the processing for downloading. """
process: list = []
for url in self.urls:
p1 = Process(target=self.tools, args=(url,))
process.append(p1)
p1.start()
if self.parallel_downloads:
for url in self.urls:
p1 = Process(target=self.tools, args=(url,))
process.append(p1)
p1.start()
for proc in process:
proc.join()
for proc in process:
proc.join()
else:
for url in self.urls:
self.tools(url)
def tools(self, url: str) -> None:
""" Downloader tools wget, curl and lftp. """

View file

@ -73,7 +73,8 @@ class FormConfigs(Configs):
def check_configs(self, tags: list) -> bool:
""" Check for true of false values. """
keys: list = ['COLORS', 'DIALOG', 'SILENT_MODE', 'ASCII_CHARACTERS', 'PONCE_REPO', 'ASK_QUESTION']
keys: list = ['COLORS', 'DIALOG', 'SILENT_MODE', 'ASCII_CHARACTERS',
'PONCE_REPO', 'ASK_QUESTION', 'PARALLEL_DOWNLOADS']
values: list = ['true', 'false']
for key, value in zip(self.configs['CONFIGS'].keys(), tags):
@ -106,7 +107,8 @@ class FormConfigs(Configs):
line = f' {key} = "{value}"\n'
if line.lstrip().startswith(('COLORS =', 'DIALOG =', 'SILENT_MODE =',
'ASCII_CHARACTERS =', 'PONCE_REPO =', 'ASK_QUESTION =')):
'ASCII_CHARACTERS =', 'PONCE_REPO =',
'ASK_QUESTION =', 'PARALLEL_DOWNLOADS =')):
line = line.replace('"', '')
patch_toml.write(line)