debuggers.hg

changeset 22091:2940165380de

tools/python: fix xm list for Python 2.7

This patch fixes
Unexpected error: <type 'exceptions.AttributeError'>
This is due to xmlrpc changes in Python 2.7. This patch should
fixe it for both old and new versions.

Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Michael Young <m.a.young@durham.ac.uk>
date Thu Aug 19 17:09:30 2010 +0100 (2010-08-19)
parents 60746a2c14a6
children 8ca0bebfb48b
files tools/python/xen/util/xmlrpcclient.py tools/python/xen/util/xmlrpclib2.py
line diff
     1.1 --- a/tools/python/xen/util/xmlrpcclient.py	Thu Aug 19 16:24:13 2010 +0100
     1.2 +++ b/tools/python/xen/util/xmlrpcclient.py	Thu Aug 19 17:09:30 2010 +0100
     1.3 @@ -22,6 +22,7 @@ import socket
     1.4  import string
     1.5  import xmlrpclib
     1.6  from types import StringTypes
     1.7 +from sys import hexversion
     1.8  
     1.9  
    1.10  try:
    1.11 @@ -54,7 +55,12 @@ class UnixTransport(xmlrpclib.Transport)
    1.12          return xmlrpclib.Transport.request(self, host, '/RPC2',
    1.13                                             request_body, verbose)
    1.14      def make_connection(self, host):
    1.15 -        return HTTPUnix(self.__handler)
    1.16 +        if hexversion < 0x02070000:
    1.17 +            # python 2.6 or earlier
    1.18 +            return HTTPUnix(self.__handler)
    1.19 +        else:
    1.20 +            # xmlrpclib.Transport changed in python 2.7
    1.21 +            return HTTPUnixConnection(self.__handler)
    1.22  
    1.23  
    1.24  # We need our own transport for HTTPS, because xmlrpclib.SafeTransport is
     2.1 --- a/tools/python/xen/util/xmlrpclib2.py	Thu Aug 19 16:24:13 2010 +0100
     2.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Thu Aug 19 17:09:30 2010 +0100
     2.3 @@ -58,6 +58,9 @@ def stringify(value):
     2.4  # some bugs in Keep-Alive handling and also enabled it by default
     2.5  class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
     2.6      protocol_version = "HTTP/1.1"
     2.7 +    # xend crashes in python 2.7 unless disable_nagle_algorithm = False
     2.8 +    # it isn't used in earlier versions so it is harmless to set it generally
     2.9 +    disable_nagle_algorithm = False
    2.10  
    2.11      def __init__(self, hosts_allowed, request, client_address, server):
    2.12          self.hosts_allowed = hosts_allowed