From d806c844ac54fe48c13bd5beb2a4c01f993aa251 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Mon, 17 Feb 2014 17:03:54 +0000 Subject: deploy: Fix double exception in rawdisk.write If the disk image was not yet created then the os.remove() call fails and the original exception gets lost, causing confusion and sadness. Also print status earlier on failure --- morphlib/exts/rawdisk.write | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/morphlib/exts/rawdisk.write b/morphlib/exts/rawdisk.write index bde9d67d..87edf7bf 100755 --- a/morphlib/exts/rawdisk.write +++ b/morphlib/exts/rawdisk.write @@ -50,9 +50,10 @@ class RawDiskWriteExtension(morphlib.writeexts.WriteExtension): self.create_local_system(temp_root, location) self.status(msg='Disk image has been created at %s' % location) except Exception: - os.remove(location) self.status(msg='Failure to create disk image at %s' % location) + if os.path.exists(location): + os.remove(location) raise def upgrade_local_system(self, raw_disk, temp_root): -- cgit v1.2.1