summaryrefslogtreecommitdiff
path: root/morphlib/ostreeartifactcache.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/ostreeartifactcache.py')
-rw-r--r--morphlib/ostreeartifactcache.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/morphlib/ostreeartifactcache.py b/morphlib/ostreeartifactcache.py
index 40f724ca..3cc4a0fe 100644
--- a/morphlib/ostreeartifactcache.py
+++ b/morphlib/ostreeartifactcache.py
@@ -31,11 +31,15 @@ from morphlib.artifactcachereference import ArtifactCacheReference
class OSTreeArtifactCache(object):
"""Class to provide the artifact cache API using an OSTree repo."""
- def __init__(self, cachedir, status_cb=None):
+ def __init__(self, cachedir, status_cb=None, runcmd=cliapp.runcmd,
+ verbose=False):
repo_dir = os.path.join(cachedir, 'repo')
self.repo = morphlib.ostree.OSTreeRepo(repo_dir)
self.cachedir = cachedir
+
self.status_cb = status_cb
+ self.runcmd = runcmd
+ self.verbose = verbose
def status(self, *args, **kwargs):
if self.status_cb is not None:
@@ -44,19 +48,21 @@ class OSTreeArtifactCache(object):
@contextlib.contextmanager
def _get_file_from_remote(self, artifact, remote, metadata_name=None):
if metadata_name:
- handle = remote.get_artifact_metadata(artifact, metadata_name)
+ url = remote.artifact_metadata_url(artifact, metadata_name)
self.status(
msg='Downloading %(name)s %(metadata_name)s as a file.',
chatty=True, name=artifact.name, metadata_name=metadata_name)
else:
- handle = remote.get(artifact)
+ url = remote.url(artifact)
self.status(
msg='Downloading %(name)s as a tarball.', chatty=True,
name=artifact.name)
try:
temporary_download = tempfile.NamedTemporaryFile(dir=self.cachedir)
- shutil.copyfileobj(handle, temporary_download)
+ morphlib.util.fetch_url(
+ url, temporary_download.name, runcmd=self.runcmd,
+ progress_on_stdout=self.verbose)
yield temporary_download.name
finally:
temporary_download.close()