diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-02-17 17:03:54 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-03-04 14:47:24 +0000 |
commit | d806c844ac54fe48c13bd5beb2a4c01f993aa251 (patch) | |
tree | 8a555344629d4a2897bfbda23242d9075baf795e /morphlib/exts | |
parent | f0f7d9804dd0b718c245e43d87114f04f35810f8 (diff) | |
download | morph-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
Diffstat (limited to 'morphlib/exts')
-rwxr-xr-x | morphlib/exts/rawdisk.write | 3 |
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): |