ia64/xen-unstable

changeset 9529:d5f8280c1fa9

Fix the ProtocolError seen when the server throws an exception and running
under Python 2.3; traceback.format_exc was introduced in 2.4, so we can't use
it.

Added some exception logging.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Mar 30 11:51:44 2006 +0100 (2006-03-30)
parents 9239f190736d
children 7a3f07a33487
files tools/python/xen/util/xmlrpclib2.py
line diff
     1.1 --- a/tools/python/xen/util/xmlrpclib2.py	Thu Mar 30 00:11:53 2006 +0100
     1.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Thu Mar 30 11:51:44 2006 +0100
     1.3 @@ -23,9 +23,13 @@ An enhanced XML-RPC client/server interf
     1.4  from httplib import HTTPConnection, HTTP
     1.5  from xmlrpclib import Transport
     1.6  from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
     1.7 -import xmlrpclib, socket, os, traceback
     1.8 +import xmlrpclib, socket, os
     1.9  import SocketServer
    1.10  
    1.11 +import xen.xend.XendClient
    1.12 +from xen.xend.XendLogging import log
    1.13 +
    1.14 +
    1.15  # A new ServerProxy that also supports httpu urls.  An http URL comes in the
    1.16  # form:
    1.17  #
    1.18 @@ -60,8 +64,7 @@ class ServerProxy(xmlrpclib.ServerProxy)
    1.19                                         verbose, allow_none)
    1.20  
    1.21  # This is a base XML-RPC server for TCP.  It sets allow_reuse_address to
    1.22 -# true, and has an improved marshaller that serializes unknown exceptions
    1.23 -# with full traceback information.
    1.24 +# true, and has an improved marshaller that logs and serializes exceptions.
    1.25  
    1.26  class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
    1.27      allow_reuse_address = True
    1.28 @@ -80,10 +83,10 @@ class TCPXMLRPCServer(SocketServer.Threa
    1.29                                         allow_none=1)
    1.30          except xmlrpclib.Fault, fault:
    1.31              response = xmlrpclib.dumps(fault)
    1.32 -        except:
    1.33 +        except Exception, exn:
    1.34 +            log.exception(exn)
    1.35              response = xmlrpclib.dumps(
    1.36 -                xmlrpclib.Fault(1, traceback.format_exc())
    1.37 -                )
    1.38 +                xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
    1.39  
    1.40          return response
    1.41