diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-11 20:11:03 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-06-11 20:11:03 -0700 |
commit | 3a74809e375f32e491d20fc303ad9220aae555d8 (patch) | |
tree | 74a7266bc56ecd2e92f74a1bd6cb990f5820a79c /cloudinit | |
parent | b46190b8bb0aaa5a45245df5490f543e6c6497cb (diff) | |
download | vyos-cloud-init-3a74809e375f32e491d20fc303ad9220aae555d8.tar.gz vyos-cloud-init-3a74809e375f32e491d20fc303ad9220aae555d8.zip |
Add centering method + more descriptive mount failure exception message.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/util.py | 11 |
1 files changed, 9 insertions, 2 deletions
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: |