Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
On 20/01/2015 06:45, lvroyce(a)linux.vnet.ibm.com wrote:
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
When check remote iso, we open an url without close it.
fix this using contextlib.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/isoinfo.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
index fb87949..34e526c 100644
--- a/src/kimchi/isoinfo.py
+++ b/src/kimchi/isoinfo.py
@@ -17,6 +17,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import contextlib
import glob
import platform
import os
@@ -414,8 +415,8 @@ lang=en#!/wiki/W51a7ffcf4dfd_4b40_9d82_446ebc23c550/page/PowerLinux\
request = urllib2.Request(self.path)
range_header = "bytes=%d-%d" % (offset, offset + size - 1)
request.add_header("range", range_header)
- response = urllib2.urlopen(request)
- data = response.read()
+ with contextlib.closing(urllib2.urlopen(request)) as response:
+ data = response.read()
else:
with open(self.path) as fd:
fd.seek(offset)