Fixed Exception dialog disapearing after a view second when exception occurs during app startup.
Problem was caused by splashscreen timeout, wx closing averything else if there is no more main frame.
Changes:
- no more timeout for splashscreen
- use wx.App OnInit method to give first operation to mainloop, object are then now created in mainloop
- main loop is then created _before_ showing splash screen
- no more wxyield or wx processevent tricks needed to display splash screen
- exception handler not blocking anymore on dialog (callafter)
- because of mainloop being there before everything, exit must be called explicitely if exception caught during startup -> exit parameter in handle_exception + try/except around startup calls
UNTESTED ON WINDOWS
from __future__ import absolute_import
import sys
import gluon.contrib.simplejson as simplejson
class JSONRPCServiceBase(object):
def __init__(self):
self.methods = {}
def response(self, id, result):
return simplejson.dumps({'version': '1.1', 'id': id,
'result': result, 'error': None})
def error(self, id, code, message):
return simplejson.dumps({
'id': id,
'version': '1.1',
'error': {'name': 'JSONRPCError',
'code': code,
'message': message}
})
def add_method(self, name, method):
self.methods[name] = method
def process(self, data):
data = simplejson.loads(data)
id, method, params = data["id"], data["method"], data["params"]
if method in self.methods:
try:
result = self.methods[method](*params)
return self.response(id, result)
except Exception:
etype, eval, _etb = sys.exc_info()
return self.error(id, 100, 'Exception %s: %s' % (etype, eval))
except BaseException:
etype, eval, _etb = sys.exc_info()
return self.error(id, 100, '%s: %s' % (etype.__name__, eval))
else:
return self.error(id, 100, 'method "%s" does not exist' % method)
def listmethods(self):
return self.methods.keys()