try:
// Send an HTTP request for the tarball.
response = self._request("GET", remote_path)
if response is None:
return None
with temporary_file() as outfile:
total_bytes = 0
// Read the data in a loop.
for chunk in response.iter_content(self.READ_SIZE_BYTES):
outfile.write(chunk)
total_bytes += len(chunk)
outfile.close()
self.log.debug("Read %d bytes from artifact cache at %s" %
(total_bytes,self._url_string(remote_path)))
// Extract the tarfile.
artifact = TarballArtifact(self.artifact_root, outfile.name, self.compression)
artifact.extract()
return artifact
except Exception as e:
self.log.warn("Error while reading from remote artifact cache: %s" % e)
return None