summaryrefslogtreecommitdiff
path: root/morphlib/mountableimage.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/mountableimage.py')
-rw-r--r--morphlib/mountableimage.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/morphlib/mountableimage.py b/morphlib/mountableimage.py
index 3d29a516..f767228a 100644
--- a/morphlib/mountableimage.py
+++ b/morphlib/mountableimage.py
@@ -15,6 +15,7 @@
import cliapp
+import logging
import os
import tempfile
import gzip
@@ -45,7 +46,9 @@ class MountableImage(object): # pragma: no cover
infh = gzip.open(path, "rb")
morphlib.util.copyfileobj(infh, outfh)
infh.close()
- except:
+ except BaseException, e:
+ logging.error('Caught exception: %s' % str(e))
+ logging.info('Removing temporary file %s' % self.temp_path)
os.unlink(self.temp_path)
raise
self.app.status(msg=' Mounting image at %(path)s',
@@ -62,17 +65,19 @@ class MountableImage(object): # pragma: no cover
chatty=True)
try:
morphlib.fsutils.unmount(self.app.runcmd, mount_point)
- except:
- pass
+ except BaseException, e:
+ logging.info('Ignoring error when unmounting: %s' % str(e))
try:
morphlib.fsutils.undo_device_mapping(self.app.runcmd, path)
- except:
- pass
+ except BaseException, e:
+ logging.info(
+ 'Ignoring error when undoing device mapping: %s' % str(e))
try:
os.rmdir(mount_point)
os.unlink(path)
- except:
- pass
+ except BaseException, e:
+ logging.info(
+ 'Ignoring error when removing temporary files: %s' % str(e))
def __enter__(self):
return self.setup(self.artifact_path)