Fixed raise an exitcode

This commit is contained in:
Dimitris Zlatanidis 2023-01-08 23:30:45 +02:00
parent 7abf5f114c
commit db9ef8d8e9

View file

@ -26,18 +26,20 @@ class Downloader:
self.red = self.color['red']
self.blue = self.color['blue']
self.byellow = f'{self.bold}{self.yellow}'
self.bred = f'{self.bold}{self.red}'
self.endc = self.color['endc']
self.progress = ProgressBar()
self.done = 'Done'
self.stderr = None
self.stdout = None
self.output = 0
def wget(self):
""" Wget downloader. """
self.output = subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
output = subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
shell=True, stderr=self.stderr, stdout=self.stdout)
if output != 0:
raise SystemExit(1)
def check_if_downloaded(self):
""" Checks if the file downloaded. """
file = self.url.split('/')[-1]
@ -48,6 +50,7 @@ class Downloader:
def download(self):
""" Starting multiprocessing download process. """
if self.configs.view_mode == 'new':
done = f' {self.byellow} Done{self.endc}'
self.stderr = subprocess.DEVNULL
self.stdout = subprocess.DEVNULL
@ -65,7 +68,9 @@ class Downloader:
# Terminate process 2 if process 1 finished
if not p1.is_alive():
print(f'{self.endc}{self.byellow} {self.done}{self.endc}', end='')
if p1.exitcode != 0:
done = f' {self.bred} Failed{self.endc}'
print(f'{self.endc}{done}', end='')
p2.terminate()
# Wait until process 2 finish