mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-06 08:46:21 +01:00
Updated for binary download
This commit is contained in:
parent
2e03f6c485
commit
77452ec5fb
2 changed files with 39 additions and 22 deletions
|
@ -6,54 +6,67 @@ import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
from slpkg.sbos.queries import SBoQueries
|
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.downloader import Downloader
|
from slpkg.downloader import Downloader
|
||||||
from slpkg.views.views import ViewMessage
|
from slpkg.views.views import ViewMessage
|
||||||
|
from slpkg.sbos.queries import SBoQueries
|
||||||
from slpkg.repositories import Repositories
|
from slpkg.repositories import Repositories
|
||||||
|
from slpkg.binaries.queries import BinQueries
|
||||||
from slpkg.models.models import session as Session
|
from slpkg.models.models import session as Session
|
||||||
|
|
||||||
|
|
||||||
class Download(Configs, Utilities):
|
class Download(Configs):
|
||||||
""" Download the slackbuilds with the sources only. """
|
""" Download the slackbuilds with the sources only. """
|
||||||
|
|
||||||
def __init__(self, directory: Path, flags: list):
|
def __init__(self, directory: Path, flags: list):
|
||||||
super(Configs, self).__init__()
|
super(Configs, self).__init__()
|
||||||
super(Utilities, self).__init__()
|
|
||||||
self.flags: list = flags
|
self.flags: list = flags
|
||||||
self.directory: Path = directory
|
self.directory: Path = directory
|
||||||
self.repos = Repositories()
|
|
||||||
|
|
||||||
|
self.repos = Repositories()
|
||||||
|
self.utils = Utilities()
|
||||||
self.session = Session
|
self.session = Session
|
||||||
|
|
||||||
self.flag_directory: list = ['-z=', '--directory=']
|
self.flag_directory: list = ['-z=', '--directory=']
|
||||||
|
self.flag_binary: list = ['-B', '--binary']
|
||||||
|
|
||||||
def packages(self, slackbuilds: list) -> None:
|
def packages(self, packages: list, repo=None) -> None:
|
||||||
""" Download the package only. """
|
""" Download the package only. """
|
||||||
view = ViewMessage(self.flags)
|
view = ViewMessage(self.flags)
|
||||||
view.download_packages(slackbuilds, self.directory)
|
view.download_packages(packages, self.directory)
|
||||||
view.question()
|
view.question()
|
||||||
|
|
||||||
download_path: Path = self.download_only_path
|
download_path: Path = self.download_only_path
|
||||||
if self.is_option(self.flag_directory, self.flags):
|
if self.utils.is_option(self.flag_directory, self.flags):
|
||||||
download_path: Path = self.directory
|
download_path: Path = self.directory
|
||||||
|
|
||||||
start: float = time.time()
|
start: float = time.time()
|
||||||
for sbo in slackbuilds:
|
for pkg in packages:
|
||||||
location: str = SBoQueries(sbo).location()
|
|
||||||
|
if self.utils.is_option(self.flag_binary, self.flags):
|
||||||
|
mirror: str = BinQueries(pkg, repo).mirror()
|
||||||
|
location: str = BinQueries(pkg, repo).location()
|
||||||
|
package: str = BinQueries(pkg, repo).package_bin()
|
||||||
|
|
||||||
|
url = [f'{mirror}{location}/{package}']
|
||||||
|
|
||||||
|
down = Downloader(self.tmp_slpkg, url, self.flags)
|
||||||
|
down.download()
|
||||||
|
|
||||||
if self.repos.ponce_repo:
|
|
||||||
ponce_repo_path_package = Path(self.repos.ponce_repo_path, location, sbo)
|
|
||||||
shutil.copytree(ponce_repo_path_package, Path(download_path, sbo))
|
|
||||||
else:
|
else:
|
||||||
file: str = f'{sbo}{self.repos.sbo_repo_tar_suffix}'
|
location: str = SBoQueries(pkg).location()
|
||||||
url: list = [f'{self.repos.sbo_repo_mirror}{location}/{file}']
|
if self.repos.ponce_repo:
|
||||||
down_sbo = Downloader(download_path, url, self.flags)
|
ponce_repo_path_package = Path(self.repos.ponce_repo_path, location, pkg)
|
||||||
down_sbo.download()
|
shutil.copytree(ponce_repo_path_package, Path(download_path, pkg))
|
||||||
|
else:
|
||||||
|
file: str = f'{pkg}{self.repos.sbo_repo_tar_suffix}'
|
||||||
|
url: list = [f'{self.repos.sbo_repo_mirror}{location}/{file}']
|
||||||
|
down_sbo = Downloader(download_path, url, self.flags)
|
||||||
|
down_sbo.download()
|
||||||
|
|
||||||
sources = SBoQueries(sbo).sources()
|
sources = SBoQueries(pkg).sources()
|
||||||
down_source = Downloader(download_path, sources, self.flags)
|
down_source = Downloader(download_path, sources, self.flags)
|
||||||
down_source.download()
|
down_source.download()
|
||||||
|
|
||||||
elapsed_time: float = time.time() - start
|
elapsed_time: float = time.time() - start
|
||||||
self.finished_time(elapsed_time)
|
self.utils.finished_time(elapsed_time)
|
||||||
|
|
|
@ -212,6 +212,10 @@ class Argparse(Configs):
|
||||||
self.flag_short_no_silent,
|
self.flag_short_no_silent,
|
||||||
self.flag_directory,
|
self.flag_directory,
|
||||||
self.flag_short_directory,
|
self.flag_short_directory,
|
||||||
|
self.flag_binary,
|
||||||
|
self.flag_short_binary,
|
||||||
|
self.flag_bin_repository,
|
||||||
|
self.flag_short_bin_repository,
|
||||||
self.flag_parallel,
|
self.flag_parallel,
|
||||||
self.flag_short_parallel
|
self.flag_short_parallel
|
||||||
],
|
],
|
||||||
|
@ -613,9 +617,9 @@ class Argparse(Configs):
|
||||||
if self.utils.is_option(self.flag_searches, self.flags):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose_packages(packages, command)
|
packages: list = self.choose_packages(packages, command)
|
||||||
|
|
||||||
self.check.exists_in_the_database(packages)
|
self.check.exists_in_the_database(packages, self.binary_repo)
|
||||||
download = Download(self.directory, self.flags)
|
download = Download(self.directory, self.flags)
|
||||||
download.packages(packages)
|
download.packages(packages, self.binary_repo)
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help_short(1)
|
self.usage.help_short(1)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue