Commit 85eabd23 authored by Julien Muchembled's avatar Julien Muchembled

download*: new alternate-url option

parent 8a9e3766
......@@ -339,6 +339,17 @@ In case of checksum mismatch::
Error: MD5 checksum mismatch downloading '...'
>>> ls('parts')
option: alternate-url
---------------------
Alternate URL. If supported by Buildout, it is used as fallback if the main
URL (`url` option) fails at HTTP level.
Useful when a version of a resource can only be downloaded with a temporary
URL as long as it's the last version, and this version is then moved to a
permanent place when a newer version is released: `url` shall be the final URL
and `alternate-url` the temporary one.
option: mode
------------
......@@ -462,6 +473,11 @@ option: md5sum
An MD5 checksum can be specified to check the downloaded file, like for the
``download`` recipe. However, if unset, updating the part does nothing.
option: alternate-url
---------------------
See the ``download`` recipe.
option: environment
-------------------
......
......@@ -36,6 +36,7 @@ class Recipe(object):
def __init__(self, buildout, name, options):
self._buildout = buildout['buildout']
self._url = options['url']
self._alternate = options.get('alternate-url')
self._md5sum = options.get('md5sum') or None
self._name = name
mode = options.get('mode')
......@@ -72,8 +73,10 @@ class Recipe(object):
return [destination]
def _download(self):
alternate = self._alternate
download.Download(self._buildout, hash_name=True)(
self._url, self._md5sum, self._destination)
self._url, self._md5sum, self._destination,
**({'alternate_url': alternate} if alternate else {}))
if self._mode is not None:
os.chmod(self._destination, self._mode)
......
......@@ -61,8 +61,10 @@ class Recipe(EnvironMixin):
def _install(self):
location = self._shared.location
alternate = self.options.get('alternate-url')
path, is_temp = download.Download(self.buildout['buildout'],
hash_name=True)(self._url, self.options.get('md5sum') or None)
hash_name=True)(self._url, self.options.get('md5sum') or None,
**({'alternate_url': alternate} if alternate else {}))
try:
archive_util.extraction_drivers = patched_extraction_drivers
# ad-hoc support for .xz and .lz archive
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment