Downloads and installs (optionally compressed) files.
Project description
Downloads and installs files
Simple light API to download and install files. If the file appears to be a
compressed file by ending with zip, tar.gz, tgz etc, then also un-compress
the file after it is downloaded.
Documentation
Obtaining
The easiest way to install the command line program is via the pip installer:
pip3 install zensols.install
Binaries are also available on pypi.
Usage
The below code is given in the example.
First create the installer configuration with each file to be installed as a
resource as a file install.conf:
[zip_resource]
class_name = zensols.install.Resource
url = https://github.com/plandes/zenbuild/archive/refs/tags/general_build.zip
# we have to give the name of the diretory in the zip file so the program knows
# what to unzip; otherwise it is named from the section, or file if `None`
name = zenbuild-general_build
# uncomment below to keep the `zenbuild-general_build.zip` zip file
#clean_up = False
[downloader]
class_name = zensols.install.Downloader
#use_progress_bar = False
[installer]
class_name = zensols.install.Installer
downloader = instance: downloader
# uncomment the below line, then comment out `base_directory` to use the
# package name (using the zensols.cli.ApplicationFactory--see example); using
# `package_resource` will in install a ~/.<package name> install directory
base_directory = path: install_dir
#package_resource = ${package:name}
resources = instance: list: zip_resource
Now use the configuration to create the installer and call it:
import logging
from zensols.config import IniConfig, ImportConfigFactory
from zensols.install import Installer
logging.basicConfig(level=logging.INFO)
fac = ImportConfigFactory(IniConfig('install.conf'))
installer: Installer = fac.instance('installer')
installer.install()
This code creates a new directory with the un-zipped files in install_dir:
INFO:zensols.install.installer:installing zenbuild-general_build to install_dir/zenbuild-general_build
INFO:zensols.install.download:creating directory: install_dir
INFO:zensols.install.download:downloading https://github.com/plandes/zenbuild/archive/refs/tags/general_build.zip to install_dir/zenbuild-general_build.zip
general_build.zip: 16.4kB [00:00, 40.1kB/s]
INFO:zensols.install.installer:uncompressing install_dir/zenbuild-general_build.zip to install_dir
patool: Extracting install_dir/zenbuild-general_build.zip ...
patool: ... install_dir/zenbuild-general_build.zip extracted to `install_dir'.
INFO:zensols.install.installer:cleaning up downloaded file: install_dir/zenbuild-general_build.zip
First the program checks to see if the target directory (name property in the
zip_resource section) exists. It then downloads it when it can't find either
the target directory or the downloaded file.
If the program is run a second time, there will be no output since the installed directory now exists.
Changelog
An extensive changelog is available here.
License
Copyright (c) 2021 - 2022 Paul Landes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zensols.install-0.0.10-py3.10.egg.
File metadata
- Download URL: zensols.install-0.0.10-py3.10.egg
- Upload date:
- Size: 20.1 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94b8f651f63fa539b1551bc3a71cb1f848ddc4b78dbfb25a8320631275828426
|
|
| MD5 |
deba7fc61cbb063aea2528a1648a0538
|
|
| BLAKE2b-256 |
a4b6b7aeba8a9f2758d1d74e8ac0bf7f4881206d753ff31befbe8cea7ee94205
|
File details
Details for the file zensols.install-0.0.10-py3-none-any.whl.
File metadata
- Download URL: zensols.install-0.0.10-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e902acb42480fd9f6e57a02f4fb48bea2aa57bcd62bafe34c77f56ead2240d53
|
|
| MD5 |
3f3ef4d8f8dc32d545f36bbd5d39db44
|
|
| BLAKE2b-256 |
fc7f8c24f3cf611f4cad3df1c9cd87263beaab5e487bc2afe9997d092758094d
|