summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-02-17 17:03:54 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-03-04 14:47:24 +0000
commitd806c844ac54fe48c13bd5beb2a4c01f993aa251 (patch)
tree8a555344629d4a2897bfbda23242d9075baf795e
parentf0f7d9804dd0b718c245e43d87114f04f35810f8 (diff)
downloadmorph-d806c844ac54fe48c13bd5beb2a4c01f993aa251.tar.gz
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
-rwxr-xr-xmorphlib/exts/rawdisk.write3
1 files changed, 2 insertions, 1 deletions
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):