projects_view = ProjectListView(projects)
projects_view.run()
except Exception, e:
- import appuifw,traceback
- trace = traceback.extract_tb(sys.exc_info()[2])
- print e,trace
- def display(objects):
- strings=[]
- for object in objects:
- strings.append(u'%s'%object)
- appuifw.selection_list(strings)
+ import appuifw,traceback,os
+ print e
- error_text = unicode(repr(e.args))
+ (type, value, tb) = sys.exc_info()
+ lines = []
+
+ # Create error message
+ for line in traceback.format_exception_only(type, value):
+ lines.append(unicode(line))
+ lines.append("\n")
+
+ # Create stacktrace
+ trace = traceback.extract_tb(tb)
+ trace.reverse()
+
+ basedir = os.path.dirname(__file__) + os.sep
+ for (file, line, func, code) in trace:
+ # Remove the basedir from any filename, since it is not so
+ # interesting but takes up precious space.
+ if file.startswith(basedir):
+ file = file[len(basedir):]
+ lines.append(u'\n%s:%s\nin %s:\n%s\n' % (file, line, func, code))
+
+ # Create and fill an error dialog
t = appuifw.Text()
- for trace_line in trace:
- formatted_trace_line = u'\nIn %s line %s: %s "%s"'%trace_line
+ for line in lines:
if logger:
- logger.log(formatted_trace_line,1)
- t.add(formatted_trace_line)
- if logger:
- logger.log(error_text,1)
- t.add(error_text)
+ logger.log(line,1)
+ t.add(line)
+
+ # Put the focus back at the top
+ t.set_pos(0)
+
+ # Create a lock to wait on
lock = e32.Ao_lock()
+
+ # Set up the dialog
appuifw.app.menu=[(u'Exit', lock.signal)]
appuifw.app.title=u'Error'
appuifw.app.body=t
appuifw.app.exit_key_handler=lock.signal
+
+ # Wait until the exit option or button is chosen
lock.wait()
# Exit app when script returns
if logger:
logger.close()
-run()
+try:
+ run()
+except:
+ import traceback
+ traceback.print_exc()
#tr.stop()