mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-13 20:01:48 +01:00
Added check to download
This commit is contained in:
parent
29c31aa832
commit
7abf5f114c
2 changed files with 17 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
Added:
|
||||
- Finished report to download only
|
||||
- The French manpage (Thanks to marav)
|
||||
- Check if the file dowwnload
|
||||
|
||||
4.4.6 - 06/01/2023
|
||||
Updated:
|
||||
|
|
|
@ -23,16 +23,27 @@ class Downloader:
|
|||
self.bold = self.color['bold']
|
||||
self.green = self.color['green']
|
||||
self.yellow = self.color['yellow']
|
||||
self.red = self.color['red']
|
||||
self.blue = self.color['blue']
|
||||
self.byellow = f'{self.bold}{self.yellow}'
|
||||
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. """
|
||||
subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
self.output = subprocess.call(f'wget {self.configs.wget_options} --directory-prefix={self.path} {self.url}',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
|
||||
def check_if_downloaded(self):
|
||||
""" Checks if the file downloaded. """
|
||||
file = self.url.split('/')[-1]
|
||||
path_file = Path(self.path, file)
|
||||
if not path_file.exists():
|
||||
raise SystemExit(f"\n{self.red}FAILED:{self.endc} '{self.blue}{self.url}{self.endc}' to download.\n")
|
||||
|
||||
def download(self):
|
||||
""" Starting multiprocessing download process. """
|
||||
|
@ -54,7 +65,7 @@ class Downloader:
|
|||
|
||||
# Terminate process 2 if process 1 finished
|
||||
if not p1.is_alive():
|
||||
print(f'{self.endc}{self.byellow} Done{self.endc}', end='')
|
||||
print(f'{self.endc}{self.byellow} {self.done}{self.endc}', end='')
|
||||
p2.terminate()
|
||||
|
||||
# Wait until process 2 finish
|
||||
|
@ -64,3 +75,5 @@ class Downloader:
|
|||
print('\x1b[?25h')
|
||||
else:
|
||||
self.wget()
|
||||
|
||||
self.check_if_downloaded()
|
||||
|
|
Loading…
Reference in a new issue