[IMP] better exception handling in netscv
bzr revid: christophe@cobalt-20081230173046-ise36mjkxdi69q4x
This commit is contained in:
parent
14cbc5b0cc
commit
dfa35ce376
|
@ -257,6 +257,9 @@ class Agent(object):
|
|||
timer.cancel()
|
||||
quit = classmethod(quit)
|
||||
|
||||
|
||||
import traceback
|
||||
|
||||
class xmlrpc(object):
|
||||
class RpcGateway(object):
|
||||
def __init__(self, name):
|
||||
|
@ -268,7 +271,6 @@ class GenericXMLRPCRequestHandler:
|
|||
Logger().notifyChannel('XMLRPC-%s' % title, LOG_DEBUG_RPC, pformat(msg))
|
||||
|
||||
def _dispatch(self, method, params):
|
||||
import traceback
|
||||
try:
|
||||
self.log('method', method)
|
||||
self.log('params', params)
|
||||
|
@ -285,13 +287,12 @@ class GenericXMLRPCRequestHandler:
|
|||
return r
|
||||
except Exception, e:
|
||||
self.log('exception', e)
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
s = str(e)
|
||||
tb = sys.exc_info()
|
||||
tb_s = "".join(traceback.format_exception(*tb))
|
||||
if tools.config['debug_mode']:
|
||||
import pdb
|
||||
tb = sys.exc_info()[2]
|
||||
pdb.post_mortem(tb)
|
||||
raise xmlrpclib.Fault(s, tb_s)
|
||||
pdb.post_mortem(tb[2])
|
||||
raise xmlrpclib.Fault(str(e), tb_s)
|
||||
|
||||
class SSLSocket(object):
|
||||
def __init__(self, socket):
|
||||
|
@ -389,10 +390,10 @@ class TinySocketClientThread(threading.Thread):
|
|||
self._logger = Logger()
|
||||
|
||||
def log(self, msg):
|
||||
self._logger.notifyChannel('NETRPC', LOG_DEBUG_RPC, msg)
|
||||
from pprint import pformat
|
||||
self._logger.notifyChannel('NETRPC', LOG_DEBUG_RPC, pformat(msg))
|
||||
|
||||
def run(self):
|
||||
import traceback
|
||||
import time
|
||||
import select
|
||||
self.running = True
|
||||
|
@ -421,14 +422,13 @@ class TinySocketClientThread(threading.Thread):
|
|||
self.log(result_from_method)
|
||||
ts.mysend(result_from_method)
|
||||
except Exception, e:
|
||||
print repr(e)
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
self.log(e)
|
||||
tb = sys.exc_info()
|
||||
tb_s = "".join(traceback.format_exception(*tb))
|
||||
if tools.config['debug_mode']:
|
||||
import pdb
|
||||
tb = sys.exc_info()[2]
|
||||
pdb.post_mortem(tb)
|
||||
e = Exception(str(e))
|
||||
self.log(str(e))
|
||||
pdb.post_mortem(tb[2])
|
||||
e = Exception(tools.ustr(e)) # avoid problems of pickeling
|
||||
ts.mysend(e, exception=True, traceback=tb_s)
|
||||
except:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue