=== modified file 'lava_dispatcher/client/master.py'
@@ -35,7 +35,6 @@
from lava_dispatcher.utils import (
download,
- download_with_cache,
logging_spawn,
logging_system,
string_to_list,
@@ -439,6 +438,11 @@
if os.path.exists(path):
shutil.rmtree(path)
+ def _download(self, url, directory):
+ lava_proxy = self.context.lava_proxy
+ lava_cookies = self.context.lava_cookies
+ return download(url, directory, lava_proxy, lava_cookies)
+
def deploy_linaro(self, hwpack=None, rootfs=None, image=None,
kernel_matrix=None, use_cache=True, rootfstype='ext3'):
LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir
@@ -473,14 +477,13 @@
# get the lock directory. The rest will skip the caching if _about_to_cache_tarballs
# return false.
should_cache = self._about_to_cache_tarballs(image, lava_cachedir)
- image_file = download_with_cache(image, tarball_dir, lava_cachedir)
+ image_file = self._download(image, tarball_dir)
image_file = self.decompress(image_file)
boot_tgz, root_tgz = self._generate_tarballs(image_file)
if should_cache:
self._cache_tarballs(image, boot_tgz, root_tgz, lava_cachedir)
else:
- lava_proxy = self.context.lava_proxy
- image_file = download(image, tarball_dir, lava_proxy)
+ image_file = self._download(image, tarball_dir)
image_file = self.decompress(image_file)
boot_tgz, root_tgz = self._generate_tarballs(image_file)
# remove the cached tarballs
=== modified file 'lava_dispatcher/context.py'
@@ -63,6 +63,10 @@
return proxy
@property
+ def lava_cookies(self):
+ return self.config.get("LAVA_COOKIES", None)
+
+ @property
def lava_image_tmpdir(self):
return self.config.get("LAVA_IMAGE_TMPDIR")
=== modified file 'lava_dispatcher/utils.py'
@@ -29,8 +29,7 @@
import pexpect
-
-def download(url, path="", proxy=None, verbose_failure=1):
+def download(url, path="", proxy=None, cookies=None, verbose_failure=1):
urlpath = urlparse.urlsplit(url).path
filename = os.path.basename(urlpath)
if path:
@@ -42,6 +41,8 @@
else:
handlers = []
opener = urllib2.build_opener(*handlers)
+ if cookies:
+ opener.addheaders.append(('Cookie', cookies))
response = opener.open(urllib2.quote(url, safe=":/"), timeout=30)
fd = open(filename, 'wb')
shutil.copyfileobj(response, fd, 0x10000)
@@ -74,20 +75,6 @@
shutil.copy(src, dest)
-# XXX: duplication, we have similar code in lava-test, we need to move that to
-# lava.utils -> namespace as standalone package
-def download_with_cache(url, path="", cachedir=""):
- cache_loc = url_to_cache(url, cachedir)
- if os.path.exists(cache_loc):
- filename = os.path.basename(cache_loc)
- file_location = os.path.join(path, filename)
- link_or_copy_file(cache_loc, file_location)
- else:
- file_location = download(url, path)
- copy_file(file_location, cache_loc)
- return file_location
-
-
def url_to_cache(url, cachedir):
url_parts = urlparse.urlsplit(url)
path = os.path.join(cachedir, url_parts.netloc,