From 18ad481067f2460b805c24cb64f1f6d39cfb0ad4 Mon Sep 17 00:00:00 2001 From: Martin Gracik Date: Thu, 25 Feb 2010 19:14:24 +0100 Subject: [PATCH] Improve the error messages in SmartCopy --- src/pylorax/sysutils.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pylorax/sysutils.py b/src/pylorax/sysutils.py index f80018b0..e63757c8 100644 --- a/src/pylorax/sysutils.py +++ b/src/pylorax/sysutils.py @@ -325,10 +325,20 @@ class SmartCopy(object): os.unlink(dst) # copy all the files - map(lambda (src, dst): shutil.copy2(src, dst), self.copyfiles) + try: + map(lambda (src, dst): shutil.copy2(src, dst), self.copyfiles) + except shutil.Error as why: + err_msg = "error copying file {0} -> {1}: {2}" + err_msg = err_msg.format(src, dst, why) + raise SmartCopyError(err_msg) # create symlinks - map(lambda (target, name): symlink_(target, name), self.links) + try: + map(lambda (target, name): symlink_(target, name), self.links) + except OSError as why: + err_msg = "error creating symlink {0} -> {1}: {2}" + err_msg = err_msg.format(name, target, why) + raise SmartCopyError(err_msg) # XXX