mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Added curl downloader
This commit is contained in:
parent
1efcf6e70e
commit
338d76e01e
4 changed files with 31 additions and 2 deletions
|
@ -5,6 +5,7 @@ Updated:
|
||||||
- manpages for options (Thanks to marav)
|
- manpages for options (Thanks to marav)
|
||||||
Added:
|
Added:
|
||||||
- Option --file-pattern
|
- Option --file-pattern
|
||||||
|
- Curl downloader as the second option
|
||||||
|
|
||||||
4.5.1 - 16/01/2023
|
4.5.1 - 16/01/2023
|
||||||
Added:
|
Added:
|
||||||
|
|
|
@ -51,6 +51,10 @@
|
||||||
# Default is true. [true/false]
|
# Default is true. [true/false]
|
||||||
dialog = true
|
dialog = true
|
||||||
|
|
||||||
|
# You can choose downloader between wget and curl:
|
||||||
|
# Default is wget.
|
||||||
|
downloader = "wget"
|
||||||
|
|
||||||
# Wget downloader options.
|
# Wget downloader options.
|
||||||
# -c, --continue: resume getting a partially-downloaded file.
|
# -c, --continue: resume getting a partially-downloaded file.
|
||||||
# -N, --timestamping: don't re-retrieve files unless newer.
|
# -N, --timestamping: don't re-retrieve files unless newer.
|
||||||
|
@ -59,6 +63,10 @@
|
||||||
# than local.
|
# than local.
|
||||||
wget_options = "-c -N -q --show-progress"
|
wget_options = "-c -N -q --show-progress"
|
||||||
|
|
||||||
|
# Curl downloader options.
|
||||||
|
# Pass the options you want here.
|
||||||
|
curl_options = ""
|
||||||
|
|
||||||
# If silent mode is true,
|
# If silent mode is true,
|
||||||
# do not print the commands as they are executed.
|
# do not print the commands as they are executed.
|
||||||
# Default is true. [true/false]
|
# Default is true. [true/false]
|
||||||
|
|
|
@ -65,9 +65,15 @@ class Configs:
|
||||||
# Dialog utility
|
# Dialog utility
|
||||||
dialog: str = True
|
dialog: str = True
|
||||||
|
|
||||||
|
# Downloader command. Wget and curl.
|
||||||
|
downloader = 'wget'
|
||||||
|
|
||||||
# Wget options
|
# Wget options
|
||||||
wget_options = '-c -N -q --show-progress'
|
wget_options = '-c -N -q --show-progress'
|
||||||
|
|
||||||
|
# Curl options
|
||||||
|
curl_options = ''
|
||||||
|
|
||||||
# Choose the view mode
|
# Choose the view mode
|
||||||
silent_mode: str = True
|
silent_mode: str = True
|
||||||
|
|
||||||
|
@ -107,9 +113,15 @@ class Configs:
|
||||||
# Dialog utility
|
# Dialog utility
|
||||||
dialog: str = config['dialog']
|
dialog: str = config['dialog']
|
||||||
|
|
||||||
|
# Downloader command
|
||||||
|
downloader: str = config['downloader']
|
||||||
|
|
||||||
# Wget options
|
# Wget options
|
||||||
wget_options: str = config['wget_options']
|
wget_options: str = config['wget_options']
|
||||||
|
|
||||||
|
# Curl options
|
||||||
|
curl_options: str = config['curl_options']
|
||||||
|
|
||||||
# Choose the view mode
|
# Choose the view mode
|
||||||
silent_mode: str = config['silent_mode']
|
silent_mode: str = config['silent_mode']
|
||||||
except KeyError as error:
|
except KeyError as error:
|
||||||
|
|
|
@ -36,8 +36,16 @@ class Downloader(Configs):
|
||||||
|
|
||||||
def wget(self):
|
def wget(self):
|
||||||
""" Wget downloader. """
|
""" Wget downloader. """
|
||||||
self.output = subprocess.call(f'wget {self.wget_options} --directory-prefix={self.path} "{self.url}"',
|
if self.downloader == 'wget':
|
||||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
self.output = subprocess.call(f'{self.downloader} {self.wget_options} --directory-prefix={self.path} '
|
||||||
|
f'"{self.url}"', shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||||
|
elif self.downloader == 'curl':
|
||||||
|
self.output = subprocess.call(f'{self.downloader} {self.curl_options} "{self.url}" --output '
|
||||||
|
f'{self.path}/{self.filename}', shell=True, stderr=self.stderr,
|
||||||
|
stdout=self.stdout)
|
||||||
|
else:
|
||||||
|
raise SystemExit(f"{self.red}Error:{self.endc} Downloader '{self.downloader}' not supported.\n")
|
||||||
|
|
||||||
if self.output != 0:
|
if self.output != 0:
|
||||||
raise SystemExit(self.output)
|
raise SystemExit(self.output)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue