use contextlib wrapper for older python-requests

This commit is contained in:
Tomas Kopecek 2017-09-25 11:21:16 +02:00 committed by Mike McLean
parent 7e2cb6b156
commit bf0552e6de
4 changed files with 8 additions and 4 deletions

View file

@ -43,6 +43,7 @@ import pwd
import requests
import fnmatch
from ConfigParser import ConfigParser
from contextlib import closing
from optparse import OptionParser
try:
import krbV
@ -676,7 +677,7 @@ class VMExecTask(BaseTaskHandler):
else:
raise koji.BuildError('unsupported file type: %s' % type)
koji.ensuredir(os.path.dirname(localpath))
with requests.get(remote_url, stream=True) as response:
with closing(requests.get(remote_url, stream=True)) as response:
f = open(localpath, 'wb')
length = response.headers.get('content-length')
if length is None: