summaryrefslogtreecommitdiff
path: root/morphlib/builder2.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-12 14:33:30 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-12 17:01:54 +0100
commitd0111fbd2de1d046b14046f2cb0ded14d058cfdd (patch)
tree2e531268b9b9aee9ea6a5ecfd5efeb5fe6b4bf0b /morphlib/builder2.py
parente3aa8ba25847397a03a665492a0cbe4541814246 (diff)
downloadmorph-d0111fbd2de1d046b14046f2cb0ded14d058cfdd.tar.gz
Fix use of GzipFile to not assume "with" protocol
This fixes a bunch of tests so they pass on squeeze, which has a version of Python whose GzipFile doesn't support the "with" protocol.
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r--morphlib/builder2.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 856587a2..565fdf4f 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -706,9 +706,10 @@ class DiskImageBuilder(SystemKindBuilder): # pragma: no cover
self.app.status(msg='Compressing disk image',
chatty=True)
with os.fdopen(image_file_fd, "rb") as ifh:
- with gzip.GzipFile(fileobj=handle, mode="wb",
- compresslevel=1) as ofh:
- shutil.copyfileobj(ifh, ofh, 1024 * 1024)
+ ofh = gzip.GzipFile(
+ fileobj=handle, mode="wb", compresslevel=1)
+ shutil.copyfileobj(ifh, ofh, 1024 * 1024)
+ ofh.close()
except:
os.remove(image_name)