Skip to content

[Eng-7753] wb deps upgrade #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions mfr/providers/http/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ async def metadata(self):
return provider.ProviderMetadata(name, ext, content_type, unique_key, self.url)

async def download(self):
response = await aiohttp.request('GET', self.url)
if response.status >= 400:
err_resp = await response.read()
logger.error('Unable to download file: ({}) {}'.format(response.status, err_resp.decode('utf-8')))
raise exceptions.DownloadError(
'Unable to download the requested file, please try again later.',
download_url=self.url,
response=await response.text(),
code=response.status,
provider='http',
)
return streams.ResponseStreamReader(response)
async with aiohttp.request('GET', self.url) as response:
if response.status >= 400:
err_resp = await response.read()
logger.error('Unable to download file: ({}) {}'.format(response.status, err_resp.decode('utf-8')))
raise exceptions.DownloadError(
'Unable to download the requested file, please try again later.',
download_url=self.url,
response=await response.text(),
code=response.status,
provider='http',
)
return streams.ResponseStreamReader(response)
9 changes: 6 additions & 3 deletions mfr/providers/osf/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ async def download(self):
self.metrics.add('download.saw_redirect', False)
if response.status in (302, 301):
await response.release()
response = await aiohttp.request('GET', response.headers['location'])
self.metrics.add('download.saw_redirect', True)
async with aiohttp.request('GET', self.url) as response:
self.metrics.add('download.saw_redirect', True)
return streams.ResponseStreamReader(response)

return streams.ResponseStreamReader(response)

Expand Down Expand Up @@ -205,4 +206,6 @@ async def _make_request(self, method, url, *args, **kwargs):
if self.authorization:
kwargs.setdefault('headers', {})['Authorization'] = 'Bearer ' + self.token

return await aiohttp.request(method, url, *args, **kwargs)
async with aiohttp.request(method, url, *args, **kwargs) as response:
return response

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tornado==6.4.2

# WaterButler
git+https://github.com/CenterForOpenScience/waterbutler.git@feature/buff-worms
# Todo: have not seen explicit 'agent' lib usage or dependency in MFR and WB for now, maybe it is worth to remove it
agent==0.1.2
google-auth==2.38.0

Expand Down
Loading