Updated for binary download

This commit is contained in:
Dimitris Zlatanidis 2023-03-27 17:50:13 +03:00
parent 2e03f6c485
commit 77452ec5fb
2 changed files with 39 additions and 22 deletions

View file

@ -6,54 +6,67 @@ import shutil
from pathlib import Path
from slpkg.configs import Configs
from slpkg.sbos.queries import SBoQueries
from slpkg.utilities import Utilities
from slpkg.downloader import Downloader
from slpkg.views.views import ViewMessage
from slpkg.sbos.queries import SBoQueries
from slpkg.repositories import Repositories
from slpkg.binaries.queries import BinQueries
from slpkg.models.models import session as Session
class Download(Configs, Utilities):
class Download(Configs):
""" Download the slackbuilds with the sources only. """
def __init__(self, directory: Path, flags: list):
super(Configs, self).__init__()
super(Utilities, self).__init__()
self.flags: list = flags
self.directory: Path = directory
self.repos = Repositories()
self.repos = Repositories()
self.utils = Utilities()
self.session = Session
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. """
view = ViewMessage(self.flags)
view.download_packages(slackbuilds, self.directory)
view.download_packages(packages, self.directory)
view.question()
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
start: float = time.time()
for sbo in slackbuilds:
location: str = SBoQueries(sbo).location()
for pkg in packages:
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:
file: str = f'{sbo}{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()
location: str = SBoQueries(pkg).location()
if self.repos.ponce_repo:
ponce_repo_path_package = Path(self.repos.ponce_repo_path, location, pkg)
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()
down_source = Downloader(download_path, sources, self.flags)
down_source.download()
sources = SBoQueries(pkg).sources()
down_source = Downloader(download_path, sources, self.flags)
down_source.download()
elapsed_time: float = time.time() - start
self.finished_time(elapsed_time)
self.utils.finished_time(elapsed_time)

View file

@ -212,6 +212,10 @@ class Argparse(Configs):
self.flag_short_no_silent,
self.flag_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_short_parallel
],
@ -613,9 +617,9 @@ class Argparse(Configs):
if self.utils.is_option(self.flag_searches, self.flags):
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.packages(packages)
download.packages(packages, self.binary_repo)
raise SystemExit()
self.usage.help_short(1)