aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2010-12-20 10:21:20 +0000
committerKeir Fraser <keir@xen.org>2010-12-20 10:21:20 +0000
commit28574483f1d50237e3abc0c4b93ed35d90748bb7 (patch)
tree86473902a206f5678aa34756d23ac781c97728bc
parent8eb14df20c7b4c826d716cf23f4dc17eb34cf1a6 (diff)
downloadxen-28574483f1d50237e3abc0c4b93ed35d90748bb7.tar.gz
xen-28574483f1d50237e3abc0c4b93ed35d90748bb7.tar.bz2
xen-28574483f1d50237e3abc0c4b93ed35d90748bb7.zip
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> xen-unstable changeset: 22045:2940165380de xen-unstable date: Thu Aug 19 17:09:30 2010 +0100
-rw-r--r--tools/python/xen/util/xmlrpcclient.py8
-rw-r--r--tools/python/xen/util/xmlrpclib2.py3
2 files changed, 10 insertions, 1 deletions
diff --git a/tools/python/xen/util/xmlrpcclient.py b/tools/python/xen/util/xmlrpcclient.py
index 5b8831713c..d4191b7489 100644
--- a/tools/python/xen/util/xmlrpcclient.py
+++ b/tools/python/xen/util/xmlrpcclient.py
@@ -22,6 +22,7 @@ import socket
import string
import xmlrpclib
from types import StringTypes
+from sys import hexversion
try:
@@ -54,7 +55,12 @@ class UnixTransport(xmlrpclib.Transport):
return xmlrpclib.Transport.request(self, host, '/RPC2',
request_body, verbose)
def make_connection(self, host):
- return HTTPUnix(self.__handler)
+ if hexversion < 0x02070000:
+ # python 2.6 or earlier
+ return HTTPUnix(self.__handler)
+ else:
+ # xmlrpclib.Transport changed in python 2.7
+ return HTTPUnixConnection(self.__handler)
# We need our own transport for HTTPS, because xmlrpclib.SafeTransport is
diff --git a/tools/python/xen/util/xmlrpclib2.py b/tools/python/xen/util/xmlrpclib2.py
index a503de1241..065a0a3e96 100644
--- a/tools/python/xen/util/xmlrpclib2.py
+++ b/tools/python/xen/util/xmlrpclib2.py
@@ -58,6 +58,9 @@ def stringify(value):
# some bugs in Keep-Alive handling and also enabled it by default
class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
protocol_version = "HTTP/1.1"
+ # xend crashes in python 2.7 unless disable_nagle_algorithm = False
+ # it isn't used in earlier versions so it is harmless to set it generally
+ disable_nagle_algorithm = False
def __init__(self, hosts_allowed, request, client_address, server):
self.hosts_allowed = hosts_allowed