charmhelpers.fetch.archiveurl module

class charmhelpers.fetch.archiveurl.ArchiveUrlFetchHandler

Bases: charmhelpers.fetch.BaseFetchHandler

Handler to download archive files from arbitrary URLs.

Can fetch from http, https, ftp, and file URLs.

Can install either tarballs (.tar, .tgz, .tbz2, etc) or zip files.

Installs the contents of the archive in $CHARM_DIR/fetched/.

can_handle(source)

Returns True if the source can be handled. Otherwise returns a string explaining why it cannot

download(source, dest)

Download an archive file.

Parameters:
  • source (str) – URL pointing to an archive file.
  • dest (str) – Local path location to download archive file to.
download_and_validate(url, hashsum, validate='sha1')
install(source, dest=None, checksum=None, hash_type='sha1')

Download and install an archive file, with optional checksum validation.

The checksum can also be given on the source URL’s fragment. For example:

handler.install('http://example.com/file.tgz#sha1=deadbeef')
Parameters:
  • source (str) – URL pointing to an archive file.
  • dest (str) – Local destination path to install to. If not given, installs to $CHARM_DIR/archives/archive_file_name.
  • checksum (str) – If given, validate the archive file after download.
  • hash_type (str) – Algorithm used to generate checksum. Can be any hash alrgorithm supported by hashlib, such as md5, sha1, sha256, sha512, etc.
charmhelpers.fetch.archiveurl.splitpasswd(user)

urllib.splitpasswd(), but six’s support of this is missing

charmhelpers.fetch.archiveurl.splituser(host)

urllib.splituser(), but six’s support of this seems broken