From 3a74809e375f32e491d20fc303ad9220aae555d8 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 11 Jun 2012 20:11:03 -0700 Subject: Add centering method + more descriptive mount failure exception message. --- cloudinit/util.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cloudinit/util.py') diff --git a/cloudinit/util.py b/cloudinit/util.py index 6cf75916..f02fcfe9 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -316,6 +316,11 @@ def tempdir(**kwargs): del_dir(tdir) +def center(text, fill, max_len): + return '{0:{fill}{align}{size}}'.format(text, fill=fill, + align="^", size=max_len) + + def del_dir(path): LOG.debug("Recursively deleting %s", path) shutil.rmtree(path) @@ -805,8 +810,10 @@ def mount_cb(device, callback, data=None, rw=False): mountcmd.append(tmpd) subp(mountcmd) umount = tmpd - except IOError as exc: - raise MountFailedError("%s" % (exc)) + except (IOError, OSError) as exc: + raise MountFailedError(("Failed mounting %s " + "to %s due to: %s") % + (device, tmpd, exc)) mountpoint = "%s/" % tmpd with unmounter(umount): if data is None: -- cgit v1.2.3