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

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# coding=utf-8
# command line interface for the Koji build system

View file

@ -10,6 +10,7 @@ import socket
import string
import sys
import time
from contextlib import closing
from six.moves import range
try:
@ -488,7 +489,8 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None, num=No
else:
print(_("Downloading: %s") % relpath)
with requests.get(url, stream=True) as response:
with closing(requests.get(url, stream=True)) as response:
length = response.headers.get('content-length')
f = open(relpath, 'wb')
if length is None: