Working on providing good error feedback
svn: r18336
This commit is contained in:
parent
ae5e389bd7
commit
d853e2886d
@ -268,6 +268,7 @@ def send_file(request, filename, mimetype):
|
|||||||
def process_action(request, view, handle, action):
|
def process_action(request, view, handle, action):
|
||||||
from webapp.reports import import_file, export_file, download
|
from webapp.reports import import_file, export_file, download
|
||||||
from cli.plug import run_report
|
from cli.plug import run_report
|
||||||
|
import traceback
|
||||||
db = DbDjango()
|
db = DbDjango()
|
||||||
if view == "report":
|
if view == "report":
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
@ -302,17 +303,24 @@ def process_action(request, view, handle, action):
|
|||||||
str(handle),
|
str(handle),
|
||||||
args["iff"]))
|
args["iff"]))
|
||||||
if filename is not None:
|
if filename is not None:
|
||||||
import threading
|
if True: # run in background, with error handling
|
||||||
def background():
|
import threading
|
||||||
try:
|
def background():
|
||||||
import_file(db, filename, lambda n: n) # callback
|
try:
|
||||||
except:
|
import_file(db, filename, lambda n: n) # callback
|
||||||
message = "import_file failed."
|
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)
|
request.user.message_set.create(message = message)
|
||||||
threading.Thread(target=background).start()
|
return redirect("/report/")
|
||||||
message = "Your data is now being imported..."
|
|
||||||
request.user.message_set.create(message = message)
|
|
||||||
return redirect("/report/")
|
|
||||||
else:
|
else:
|
||||||
message = "No filename was provided or found."
|
message = "No filename was provided or found."
|
||||||
request.user.message_set.create(message = message)
|
request.user.message_set.create(message = message)
|
||||||
|
@ -35,7 +35,9 @@ def import_file(db, filename, callback):
|
|||||||
if format == pdata.extension:
|
if format == pdata.extension:
|
||||||
mod = pmgr.load_plugin(pdata)
|
mod = pmgr.load_plugin(pdata)
|
||||||
if not mod:
|
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
|
etype, exception, traceback = error_tuple
|
||||||
print "ERROR:", name, exception
|
print "ERROR:", name, exception
|
||||||
return False
|
return False
|
||||||
@ -89,7 +91,8 @@ def export_file(db, filename, callback):
|
|||||||
if format == pdata.extension:
|
if format == pdata.extension:
|
||||||
mod = pmgr.load_plugin(pdata)
|
mod = pmgr.load_plugin(pdata)
|
||||||
if not mod:
|
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
|
etype, exception, traceback = error_tuple
|
||||||
print "ERROR:", name, exception
|
print "ERROR:", name, exception
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user