python 2.6 does not allow specifying multiple contexts in one 'with'
statement. And it is used by RHEL6.5
Fix it by specifying just one context per 'with' statement.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/kimchi/model/storagevolumes.py | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py
index 4d0c231..50055a3 100644
--- a/src/kimchi/model/storagevolumes.py
+++ b/src/kimchi/model/storagevolumes.py
@@ -168,24 +168,24 @@ class StorageVolumesModel(object):
pool = pool_model.lookup(pool_name)
file_path = os.path.join(pool['path'], name)
- with contextlib.closing(urllib2.urlopen(url)) as response,\
- open(file_path, 'w') as volume_file:
- remote_size = response.info().getheader('Content-Length',
'-')
- downloaded_size = 0
+ with contextlib.closing(urllib2.urlopen(url)) as response:
+ with open(file_path, 'w') as volume_file:
+ remote_size = response.info().getheader('Content-Length',
'-')
+ downloaded_size = 0
- try:
- while True:
- chunk_data = response.read(READ_CHUNK_SIZE)
- if not chunk_data:
- break
-
- volume_file.write(chunk_data)
- downloaded_size += len(chunk_data)
- cb('%s/%s' % (downloaded_size, remote_size))
- except Exception, e:
- raise OperationFailed('KCHVOL0007E', {'name': name,
- 'pool': pool_name,
- 'err': e.message})
+ try:
+ while True:
+ chunk_data = response.read(READ_CHUNK_SIZE)
+ if not chunk_data:
+ break
+
+ volume_file.write(chunk_data)
+ downloaded_size += len(chunk_data)
+ cb('%s/%s' % (downloaded_size, remote_size))
+ except Exception, e:
+ raise OperationFailed('KCHVOL0007E', {'name': name,
+ 'pool': pool_name,
+ 'err': e.message})
StoragePoolModel.get_storagepool(pool_name, self.conn).refresh()
cb('OK', True)
--
1.9.3