diff --git a/src/webapp/grampsdb/views.py b/src/webapp/grampsdb/views.py index b8051e160..14faf56de 100644 --- a/src/webapp/grampsdb/views.py +++ b/src/webapp/grampsdb/views.py @@ -268,6 +268,7 @@ def send_file(request, filename, mimetype): def process_action(request, view, handle, action): from webapp.reports import import_file, export_file, download from cli.plug import run_report + import traceback db = DbDjango() if view == "report": if request.user.is_authenticated(): @@ -302,17 +303,24 @@ def process_action(request, view, handle, action): str(handle), args["iff"])) if filename is not None: - import threading - def background(): - try: - import_file(db, filename, lambda n: n) # callback - except: - message = "import_file failed." + if True: # run in background, with error handling + import threading + def background(): + try: + import_file(db, filename, lambda n: n) # callback + except: + message = "import_file failed: " + traceback.format_exc() + request.user.message_set.create(message = message) + threading.Thread(target=background).start() + message = "Your data is now being imported..." + request.user.message_set.create(message = message) + return redirect("/report/") + else: + success = import_file(db, filename, lambda n: n) # callback + if not success: + message = "Failed to load imported." request.user.message_set.create(message = message) - threading.Thread(target=background).start() - message = "Your data is now being imported..." - request.user.message_set.create(message = message) - return redirect("/report/") + return redirect("/report/") else: message = "No filename was provided or found." request.user.message_set.create(message = message) diff --git a/src/webapp/reports.py b/src/webapp/reports.py index 3c1a88b67..fbf973852 100644 --- a/src/webapp/reports.py +++ b/src/webapp/reports.py @@ -35,7 +35,9 @@ def import_file(db, filename, callback): if format == pdata.extension: mod = pmgr.load_plugin(pdata) if not mod: - for name, error_tuple in pmgr.get_fail_list(): + for item in pmgr.get_fail_list(): + name, error_tuple, pdata = item + # (filename, (exception-type, exception, traceback), pdata) etype, exception, traceback = error_tuple print "ERROR:", name, exception return False @@ -89,7 +91,8 @@ def export_file(db, filename, callback): if format == pdata.extension: mod = pmgr.load_plugin(pdata) if not mod: - for name, error_tuple in pmgr.get_fail_list(): + for item in pmgr.get_fail_list(): + name, error_tuple, pdata = item etype, exception, traceback = error_tuple print "ERROR:", name, exception return False