Add workaround for old requests in kojiwrapper
When running with requests<2.18 (i.e. on RHEL 7), streaming responses are not a context manager and need to be wrapped in contextlib.closing. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
f25489d060
commit
860360629d
@ -959,7 +959,8 @@ class KojiDownloadProxy:
|
|||||||
:param str dest: file path to store the result in
|
:param str dest: file path to store the result in
|
||||||
:returns: path to the downloaded file (same as dest) or None if the URL
|
:returns: path to the downloaded file (same as dest) or None if the URL
|
||||||
"""
|
"""
|
||||||
with self.session.get(url, stream=True) as r:
|
# contextlib.closing is only needed in requests<2.18
|
||||||
|
with contextlib.closing(self.session.get(url, stream=True)) as r:
|
||||||
if r.status_code == 404:
|
if r.status_code == 404:
|
||||||
self.logger.warning("GET %s NOT FOUND", url)
|
self.logger.warning("GET %s NOT FOUND", url)
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user