Skip to main content

Downloads and installs (optionally compressed) files.

Project description

Downloads and installs files

PyPI Python 3.7 Python 3.8 Python 3.9 Build Status

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}
installs = 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

MIT License

Copyright (c) 2021 Paul Landes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zensols.install-0.0.4-py3.9.egg (12.7 kB view details)

Uploaded Egg

zensols.install-0.0.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file zensols.install-0.0.4-py3.9.egg.

File metadata

  • Download URL: zensols.install-0.0.4-py3.9.egg
  • Upload date:
  • Size: 12.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.9.1

File hashes

Hashes for zensols.install-0.0.4-py3.9.egg
Algorithm Hash digest
SHA256 50b10a5394b779b68b436ad2cf3d08b932c4358a960cf110e97c721b7c2b9c69
MD5 1bb5292301dc500aad4b4b2d4afedb5a
BLAKE2b-256 8ce0f30a99a29a5e669191efc1b5af8fff7110670ce0835bae8cb91d68367fde

See more details on using hashes here.

File details

Details for the file zensols.install-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: zensols.install-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.9.1

File hashes

Hashes for zensols.install-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e898b51155d13376b7cc6f801e4818dda6f4812c2560ee3e3297804275f2b6bb
MD5 0d7ce5e860f2fd099e076197d5fafb89
BLAKE2b-256 5ebc00e509872fc8af71fcd4cb9f6b49216ef867b3cb907d4418b99ccdc7eab7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page