Added option --directory=

This commit is contained in:
Dimitris Zlatanidis 2023-01-16 20:29:33 +02:00
parent 75c16878f9
commit 3bd4644e77
6 changed files with 40 additions and 9 deletions

View file

@ -1,3 +1,7 @@
4.5.1 - 16/01/2023
Added:
- Option --directory= for download command
4.5.0 - 14/01/2023
Updated:
- Download first all the slackbuilds

View file

@ -57,7 +57,7 @@ Construit les scripts des Slackbuilds et les ajoute au répertoire \fB/tmp\fP.
Construit et installe les paquets dans l'ordre adéquat et enregistre également les paquets avec les dépendances à utiliser pour la suppression.
.RE
.P
.B -d, download --yes, --search, --no-silent
.B -d, download --yes, --search, --no-silent, --directory=
.RS
Télécharger les scripts et les sources des SlackBuilds sans les construire ni les installer.
.RE
@ -139,6 +139,11 @@ Essayez par exemple : \fB`slpkg install python3 --search`\fP ou \fB`slpkg downlo
Désactive le mode silencieux s'il est activé dans le fichier de configuration.
.RE
.P
--directory=
.RS
Le répertoire est le chemin où les fichiers seront enregistrés.
.RE
.P
-h | --help
.RS
Affiche l'aide.

View file

@ -57,7 +57,7 @@ Builds the Slackbuilds scripts and adds them to the /tmp directory.
Builds and installs the packages in the correct order and also logs the packages with dependencies to use for removal.
.RE
.P
.B -d, download --yes, --search, --no-silent
.B -d, download --yes, --search, --no-silent, --directory=
.RS
Download the SlackBuilds scripts and the sources without building or installing it.
.RE
@ -139,6 +139,11 @@ Example try: `slpkg install python3 --search` or `slpkg download python3 --searc
Disable silent mode if it is enabled in the configuration file.
.RE
.P
--directory=
.RS
The directory is the path where the files will be saved.
.RE
.P
-h | --help
.RS
Show help information and exit.

View file

@ -14,8 +14,10 @@ from slpkg.models.models import session as Session
class Download:
""" Download the slackbuilds with the sources only. """
def __init__(self, flags: list):
def __init__(self, directory: str, flags: list):
self.flags = flags
self.directory = directory
self.flag_directory = '--directory='
self.configs = Configs
self.session = Session
self.utils = Utilities()
@ -26,18 +28,22 @@ class Download:
view.download_packages(slackbuilds)
view.question()
download_path = self.configs.download_only
if self.flag_directory in self.flags:
download_path = self.directory
start = time.time()
for sbo in slackbuilds:
file = f'{sbo}{self.configs.sbo_tar_suffix}'
location = SBoQueries(sbo).location()
url = f'{self.configs.sbo_repo_url}/{location}/{file}'
down_sbo = Downloader(self.configs.download_only, url, self.flags)
down_sbo = Downloader(download_path, url, self.flags)
down_sbo.download()
sources = SBoQueries(sbo).sources()
for source in sources:
down_source = Downloader(self.configs.download_only, source, self.flags)
down_source = Downloader(download_path, source, self.flags)
down_source.download()
elapsed_time = time.time() - start

View file

@ -31,6 +31,7 @@ class Argparse:
def __init__(self, args: list):
self.args = args
self.flags = []
self.directory = None
self.configs = Configs
self.dialog = DialogBox()
self.utils = Utilities()
@ -51,6 +52,7 @@ class Argparse:
self.flag_full_reverse = '--full-reverse'
self.flag_search = '--search'
self.flag_no_silent = '--no-silent'
self.flag_directory = '--directory='
self.is_dialog_enabled()
@ -61,12 +63,18 @@ class Argparse:
self.flag_skip_installed,
self.flag_full_reverse,
self.flag_search,
self.flag_no_silent]
self.flag_no_silent,
self.flag_directory]
self.remove_flags()
def remove_flags(self):
""" Remove flags from args. """
for arg in self.args:
if arg.startswith(self.flag_directory):
self.directory = arg.split('=')[1]
self.args[self.args.index(arg)] = self.flag_directory
for opt in self.options:
if opt in self.args:
self.args.remove(opt)
@ -119,7 +127,8 @@ class Argparse:
'download': [
self.flag_yes,
self.flag_search,
self.flag_no_silent
self.flag_no_silent,
self.flag_directory
],
'remove': [
self.flag_yes,
@ -329,7 +338,7 @@ class Argparse:
self.check.database()
self.check.exists(packages)
download = Download(self.flags)
download = Download(self.directory, self.flags)
download.packages(packages)
raise SystemExit()
self.usage.help(1)

View file

@ -26,7 +26,8 @@ class Usage:
f' slpkg [{self.cyan}COMMAND{self.endc}] [-f, find, -w, view, -s, search, -e, dependees] <packages>\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-t, tracking] <packages>\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--yes, --jobs, --resolve-off, --reinstall]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search, --no-silent]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--skip-installed, --full-reverse, --search]\n'
f' slpkg [{self.yellow}OPTIONS{self.endc}] [--no-silent, --directory=]\n'
" \nIf you need more information please try 'slpkg --help'.")
print(args)
@ -63,6 +64,7 @@ class Usage:
f' {self.yellow}--full-reverse{self.endc} Full reverse dependency.\n'
f' {self.yellow}--search{self.endc} Search packages from the repository.\n'
f' {self.yellow}--no-silent{self.endc} Disable silent mode.\n'
f' {self.yellow}--directory={self.endc} Download files to a specific path.\n'
'\n -h, --help Show this message and exit.\n'
' -v, --version Print version and exit.\n'
'\nEdit the configuration file in the /etc/slpkg/slpkg.toml \n'