mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Fixed raise an exitcode
This commit is contained in:
parent
7abf5f114c
commit
db9ef8d8e9
1 changed files with 9 additions and 4 deletions
|
@ -26,18 +26,20 @@ class Downloader:
|
||||||
self.red = self.color['red']
|
self.red = self.color['red']
|
||||||
self.blue = self.color['blue']
|
self.blue = self.color['blue']
|
||||||
self.byellow = f'{self.bold}{self.yellow}'
|
self.byellow = f'{self.bold}{self.yellow}'
|
||||||
|
self.bred = f'{self.bold}{self.red}'
|
||||||
self.endc = self.color['endc']
|
self.endc = self.color['endc']
|
||||||
self.progress = ProgressBar()
|
self.progress = ProgressBar()
|
||||||
self.done = 'Done'
|
|
||||||
self.stderr = None
|
self.stderr = None
|
||||||
self.stdout = None
|
self.stdout = None
|
||||||
self.output = 0
|
|
||||||
|
|
||||||
def wget(self):
|
def wget(self):
|
||||||
""" Wget downloader. """
|
""" 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)
|
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||||
|
|
||||||
|
if output != 0:
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
def check_if_downloaded(self):
|
def check_if_downloaded(self):
|
||||||
""" Checks if the file downloaded. """
|
""" Checks if the file downloaded. """
|
||||||
file = self.url.split('/')[-1]
|
file = self.url.split('/')[-1]
|
||||||
|
@ -48,6 +50,7 @@ class Downloader:
|
||||||
def download(self):
|
def download(self):
|
||||||
""" Starting multiprocessing download process. """
|
""" Starting multiprocessing download process. """
|
||||||
if self.configs.view_mode == 'new':
|
if self.configs.view_mode == 'new':
|
||||||
|
done = f' {self.byellow} Done{self.endc}'
|
||||||
self.stderr = subprocess.DEVNULL
|
self.stderr = subprocess.DEVNULL
|
||||||
self.stdout = subprocess.DEVNULL
|
self.stdout = subprocess.DEVNULL
|
||||||
|
|
||||||
|
@ -65,7 +68,9 @@ class Downloader:
|
||||||
|
|
||||||
# Terminate process 2 if process 1 finished
|
# Terminate process 2 if process 1 finished
|
||||||
if not p1.is_alive():
|
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()
|
p2.terminate()
|
||||||
|
|
||||||
# Wait until process 2 finish
|
# Wait until process 2 finish
|
||||||
|
|
Loading…
Reference in a new issue