mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-17 07:48:18 +01:00
Added aria2c and curl as downloader
This commit is contained in:
parent
64f3a6caaa
commit
bd2f98ecd9
4 changed files with 46 additions and 12 deletions
|
@ -80,13 +80,17 @@ RSL_DEPS=on
|
|||
# Delete package dependencies if DEL_DEPS is on.
|
||||
# You must be careful if you enable this option because it can remove
|
||||
# packages related to distribution. Default is "off".
|
||||
DEL_DEPS=off
|
||||
DEL_DEPS=on
|
||||
|
||||
# Use colors for highlighting. Choose "on" or "off". Default is "on".
|
||||
USE_COLORS=on
|
||||
|
||||
# Wget [OPTION]. Pass wget options. Default is "-c -N".
|
||||
WGET_OPTIONS=-c -N
|
||||
# Downloader utility. Three options are supported "wget", "aria2c" and
|
||||
# "curl". Default is wget.
|
||||
DOWNDER=wget
|
||||
|
||||
# Downloader [OPTION]. Pass downloader options. Default for wget is "-c -N".
|
||||
DOWNDER_OPTIONS=-c -N
|
||||
|
||||
# Update slackpkg ChangeLog.txt file if SLACKPKG_LOG is "on".
|
||||
# Automatically synchronizes the command "slackpkg update" with
|
||||
|
|
|
@ -125,7 +125,8 @@ class MetaData(object):
|
|||
"RSL_DEPS": "on",
|
||||
"DEL_DEPS": "off",
|
||||
"USE_COLORS": "on",
|
||||
"WGET_OPTIONS": "-c -N",
|
||||
"DOWNDER": "wget",
|
||||
"DOWNDER_OPTIONS": "-c -N",
|
||||
"SLACKPKG_LOG": "on",
|
||||
"ONLY_INSTALLED": "off"
|
||||
}
|
||||
|
@ -163,7 +164,8 @@ class MetaData(object):
|
|||
rsl_deps = _conf_slpkg["RSL_DEPS"]
|
||||
del_deps = _conf_slpkg["DEL_DEPS"]
|
||||
use_colors = _conf_slpkg["USE_COLORS"]
|
||||
wget_options = _conf_slpkg["WGET_OPTIONS"]
|
||||
downder = _conf_slpkg["DOWNDER"]
|
||||
downder_options = _conf_slpkg["DOWNDER_OPTIONS"]
|
||||
slackpkg_log = _conf_slpkg["SLACKPKG_LOG"]
|
||||
only_installed = _conf_slpkg["ONLY_INSTALLED"]
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ class Config(object):
|
|||
"RSL_DEPS",
|
||||
"DEL_DEPS",
|
||||
"USE_COLORS",
|
||||
"WGET_OPTIONS",
|
||||
"DOWNDER",
|
||||
"DOWNDER_OPTIONS",
|
||||
"SLACKPKG_LOG",
|
||||
"ONLY_INSTALLED"
|
||||
]
|
||||
|
|
|
@ -37,13 +37,17 @@ class Download(object):
|
|||
self.url = url
|
||||
self.repo = repo
|
||||
self.meta = _meta_
|
||||
self.wget_options = self.meta.wget_options
|
||||
self.dir_prefix = ""
|
||||
self.downder = self.meta.downder
|
||||
self.downder_options = self.meta.downder_options
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Download files usign wget.
|
||||
"""
|
||||
dwn_count = 1
|
||||
self._directory_prefix()
|
||||
print self.downder, self.downder_options, self.dir_prefix
|
||||
for dwn in self.url:
|
||||
self.file_name = dwn.split("/")[-1]
|
||||
self._check_certificate()
|
||||
|
@ -52,15 +56,30 @@ class Download(object):
|
|||
self.meta.color["ENDC"],
|
||||
self.file_name))
|
||||
try:
|
||||
subprocess.call("wget {0} --directory-prefix={1} {2}".format(
|
||||
self.wget_options, self.path, dwn), shell=True)
|
||||
if self.downder in ["wget", "aria2c"]:
|
||||
subprocess.call("{0} {1} {2}{3} {4}".format(
|
||||
self.downder, self.downder_options,
|
||||
self.dir_prefix, self.path, dwn),
|
||||
shell=True)
|
||||
elif self.downder == "curl":
|
||||
subprocess.call("{0} {1} {2} {3}".format(
|
||||
self.downder, self.downder_options,
|
||||
dwn, self.path), shell=True)
|
||||
self._check_if_downloaded()
|
||||
dwn_count += 1
|
||||
except KeyboardInterrupt:
|
||||
print # new line at cancel
|
||||
sys.exit(0)
|
||||
|
||||
def _directory_prefix(self):
|
||||
if self.downder == "wget":
|
||||
self.dir_prefix = "--directory-prefix="
|
||||
elif self.downder == "aria2c":
|
||||
self.dir_prefix = "--dir="
|
||||
|
||||
def _check_if_downloaded(self):
|
||||
"""Check if file downloaded
|
||||
"""
|
||||
if not os.path.isfile(self.path + self.file_name):
|
||||
print("")
|
||||
Msg().template(78)
|
||||
|
@ -75,6 +94,14 @@ class Download(object):
|
|||
def _check_certificate(self):
|
||||
"""Check for certificates options for wget
|
||||
"""
|
||||
if self.file_name.startswith("jdk-") and self.repo == "sbo":
|
||||
self.wget_options += (" --no-check-certificate --header='Cookie: "
|
||||
"oraclelicense=accept-securebackup-cookie'")
|
||||
if (self.file_name.startswith("jdk-") and self.repo == "sbo" and
|
||||
self.downder == "wget"):
|
||||
certificate = (' --no-check-certificate --header="Cookie: '
|
||||
'oraclelicense=accept-securebackup-cookie"')
|
||||
Msg().template(78)
|
||||
print("| '{0}' need to go ahead downloading".format(
|
||||
certificate[:23]))
|
||||
Msg().template(78)
|
||||
self.downder_options += certificate
|
||||
if not Msg().answer() in ["y", "Y"]:
|
||||
sys.exit(0)
|
||||
|
|
Loading…
Reference in a new issue