|
|
|
@ -295,11 +295,24 @@ class Compute:
|
|
|
|
|
:returns: A file stream
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# Due to Python 3.4 limitation we can't use with and asyncio
|
|
|
|
|
# https://www.python.org/dev/peps/pep-0492/
|
|
|
|
|
# that why we wrap the answer
|
|
|
|
|
class StreamResponse:
|
|
|
|
|
def __init__(self, response):
|
|
|
|
|
self._response = response
|
|
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
|
return self._response.content
|
|
|
|
|
|
|
|
|
|
def __exit__(self):
|
|
|
|
|
self._response.close()
|
|
|
|
|
|
|
|
|
|
url = self._getUrl("/projects/{}/stream/{}".format(project.id, path))
|
|
|
|
|
response = yield from self._session().request("GET", url, auth=self._auth)
|
|
|
|
|
if response.status == 404:
|
|
|
|
|
raise aiohttp.web.HTTPNotFound(text="{} not found on compute".format(path))
|
|
|
|
|
return response.content
|
|
|
|
|
return StreamResponse(response)
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
|
def http_query(self, method, path, data=None, **kwargs):
|
|
|
|
|