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
commit0bccd86aa45da7ddde2486c21cee939dc871c53f (patch)
treee676def3f100b6a2064f3d14f8489d6966320926
parentc808549169a7704cdd5928e0d75a30ecc8036487 (diff)
downloaddefinitions-0bccd86aa45da7ddde2486c21cee939dc871c53f.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-xrawdisk.write3
1 files changed, 2 insertions, 1 deletions
diff --git a/rawdisk.write b/rawdisk.write
index bde9d67d..87edf7bf 100755
--- a/rawdisk.write
+++ b/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):