From 55b368414e45affa86b620dc56de355a65c1c79f Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Fri, 9 Mar 2018 11:06:30 -0800 Subject: [PATCH] Refs #8: added better error message when attempting to load unknown template --- atrcopy/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/atrcopy/__init__.py b/atrcopy/__init__.py index a2f3e03..e814246 100644 --- a/atrcopy/__init__.py +++ b/atrcopy/__init__.py @@ -326,7 +326,7 @@ def get_template_data(template): with open(path, "rb") as fh: data = fh.read() except: - raise InvalidDiskImage("Template disk image %s not found" % template) + raise InvalidDiskImage("Unknown template disk image %s" % template) try: with open(path + ".inf", "r") as fh: s = fh.read() @@ -339,7 +339,12 @@ def get_template_data(template): def create_image(template, name): import textwrap - data, inf = get_template_data(template) + try: + data, inf = get_template_data(template) + except InvalidDiskImage, e: + info = get_template_info() + print("Error: %s\n\n%s" % (e, info)) + return print("using %s template:\n %s" % (template, "\n ".join(textwrap.wrap(inf["description"], 77)))) if not options.dry_run: if os.path.exists(name) and not options.force: