summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinstall/tools/ipa-replica-manage2
-rw-r--r--ipalib/parameters.py2
-rw-r--r--ipalib/rpc.py52
-rw-r--r--ipapython/cookie.py2
-rw-r--r--ipapython/ipautil.py1
-rw-r--r--ipapython/nsslib.py6
-rw-r--r--ipaserver/rpcserver.py2
-rw-r--r--ipatests/test_ipalib/test_parameters.py2
-rw-r--r--ipatests/test_ipalib/test_rpc.py12
9 files changed, 44 insertions, 37 deletions
diff --git a/install/tools/ipa-replica-manage b/install/tools/ipa-replica-manage
index b09f4d3fc..845c33031 100755
--- a/install/tools/ipa-replica-manage
+++ b/install/tools/ipa-replica-manage
@@ -43,7 +43,7 @@ from ipapython.ipa_log_manager import *
from ipapython.dn import DN
from ipapython.config import IPAOptionParser
from ipaclient import ipadiscovery
-from xmlrpclib import MAXINT
+from six.moves.xmlrpc_client import MAXINT
from ipaplatform.paths import paths
# dict of command name and tuples of min/max num of args needed
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index dab235a24..89c9b5067 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -103,7 +103,7 @@ import re
import decimal
import base64
import datetime
-from xmlrpclib import MAXINT, MININT
+from six.moves.xmlrpc_client import MAXINT, MININT
from types import NoneType
import encodings.idna
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index 2cf2200d9..1d14e921c 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -21,11 +21,11 @@
"""
RPC client and shared RPC client/server functionality.
-This module adds some additional functionality on top of the ``xmlrpclib``
-module in the Python standard library. For documentation on the
-``xmlrpclib`` module, see:
+This module adds some additional functionality on top of the ``xmlrpc.client``
+module in the Python standard library (``xmlrpclib`` in Python 2).
+For documentation on the ``xmlrpclib`` module, see:
- http://docs.python.org/library/xmlrpclib.html
+ http://docs.python.org/2/library/xmlrpclib.html
Also see the `ipaserver.rpcserver` module.
"""
@@ -39,8 +39,6 @@ import locale
import base64
import json
import socket
-from xmlrpclib import (Binary, Fault, DateTime, dumps, loads, ServerProxy,
- Transport, ProtocolError, MININT, MAXINT)
import gssapi
from dns import resolver, rdatatype
@@ -71,6 +69,16 @@ from ipapython.dn import DN
from ipalib.capabilities import VERSION_WITHOUT_CAPABILITIES
from ipalib import api
+# The XMLRPC client is in "six.moves.xmlrpc_client", but pylint
+# cannot handle that
+try:
+ from xmlrpclib import (Binary, Fault, DateTime, dumps, loads, ServerProxy,
+ Transport, ProtocolError, MININT, MAXINT)
+except ImportError:
+ from xmlrpc.client import (Binary, Fault, DateTime, dumps, loads, ServerProxy,
+ Transport, ProtocolError, MININT, MAXINT)
+
+
if six.PY3:
unicode = str
@@ -138,16 +146,16 @@ def delete_persistent_client_session_data(principal):
def xml_wrap(value, version):
"""
- Wrap all ``str`` in ``xmlrpclib.Binary``.
+ Wrap all ``str`` in ``xmlrpc.client.Binary``.
- Because ``xmlrpclib.dumps()`` will itself convert all ``unicode`` instances
+ Because ``xmlrpc.client.dumps()`` will itself convert all ``unicode`` instances
into UTF-8 encoded ``str`` instances, we don't do it here.
So in total, when encoding data for an XML-RPC packet, the following
transformations occur:
* All ``str`` instances are treated as binary data and are wrapped in
- an ``xmlrpclib.Binary()`` instance.
+ an ``xmlrpc.client.Binary()`` instance.
* Only ``unicode`` instances are treated as character data. They get
converted to UTF-8 encoded ``str`` instances (although as mentioned,
@@ -173,7 +181,7 @@ def xml_wrap(value, version):
if isinstance(value, DN):
return str(value)
- # Encode datetime.datetime objects as xmlrpclib.DateTime objects
+ # Encode datetime.datetime objects as xmlrpc.client.DateTime objects
if isinstance(value, datetime.datetime):
if capabilities.client_has_capability(version, 'datetime_values'):
return DateTime(value)
@@ -197,7 +205,7 @@ def xml_unwrap(value, encoding='UTF-8'):
When decoding data from an XML-RPC packet, the following transformations
occur:
- * The binary payloads of all ``xmlrpclib.Binary`` instances are
+ * The binary payloads of all ``xmlrpc.client.Binary`` instances are
returned as ``str`` instances.
* All ``str`` instances are treated as UTF-8 encoded Unicode strings.
@@ -235,16 +243,16 @@ def xml_dumps(params, version, methodname=None, methodresponse=False,
Encode an XML-RPC data packet, transparently wraping ``params``.
This function will wrap ``params`` using `xml_wrap()` and will
- then encode the XML-RPC data packet using ``xmlrpclib.dumps()`` (from the
+ then encode the XML-RPC data packet using ``xmlrpc.client.dumps()`` (from the
Python standard library).
- For documentation on the ``xmlrpclib.dumps()`` function, see:
+ For documentation on the ``xmlrpc.client.dumps()`` function, see:
- http://docs.python.org/library/xmlrpclib.html#convenience-functions
+ http://docs.python.org/library/xmlrpc.client.html#convenience-functions
Also see `xml_loads()`.
- :param params: A ``tuple`` or an ``xmlrpclib.Fault`` instance.
+ :param params: A ``tuple`` or an ``xmlrpc.client.Fault`` instance.
:param methodname: The name of the method to call if this is a request.
:param methodresponse: Set this to ``True`` if this is a response.
:param encoding: The Unicode encoding to use (defaults to ``'UTF-8'``).
@@ -366,9 +374,9 @@ def xml_loads(data, encoding='UTF-8'):
Decode the XML-RPC packet in ``data``, transparently unwrapping its params.
This function will decode the XML-RPC packet in ``data`` using
- ``xmlrpclib.loads()`` (from the Python standard library). If ``data``
- contains a fault, ``xmlrpclib.loads()`` will itself raise an
- ``xmlrpclib.Fault`` exception.
+ ``xmlrpc.client.loads()`` (from the Python standard library). If ``data``
+ contains a fault, ``xmlrpc.client.loads()`` will itself raise an
+ ``xmlrpc.client.Fault`` exception.
Assuming an exception is not raised, this function will then unwrap the
params in ``data`` using `xml_unwrap()`. Finally, a
@@ -376,9 +384,9 @@ def xml_loads(data, encoding='UTF-8'):
and the name of the method being called. If the packet contains no method
name, ``methodname`` will be ``None``.
- For documentation on the ``xmlrpclib.loads()`` function, see:
+ For documentation on the ``xmlrpc.client.loads()`` function, see:
- http://docs.python.org/library/xmlrpclib.html#convenience-functions
+ http://docs.python.org/2/library/xmlrpclib.html#convenience-functions
Also see `xml_dumps()`.
@@ -603,7 +611,7 @@ class KerbTransport(SSLTransport):
return True
def single_request(self, host, handler, request_body, verbose=0):
- # Based on xmlrpclib.Transport.single_request
+ # Based on xmlrpc.lient.Transport.single_request
try:
h = SSLTransport.make_connection(self, host)
if verbose:
@@ -1032,7 +1040,7 @@ class JSONServerProxy(object):
self.__verbose = verbose
# FIXME: Some of our code requires ServerProxy internals.
- # But, xmlrpclib.ServerProxy's _ServerProxy__transport can be accessed
+ # But, xmlrpc.client.ServerProxy's _ServerProxy__transport can be accessed
# by calling serverproxy('transport')
self._ServerProxy__transport = transport
diff --git a/ipapython/cookie.py b/ipapython/cookie.py
index 84de94c9c..d51b005a2 100644
--- a/ipapython/cookie.py
+++ b/ipapython/cookie.py
@@ -49,7 +49,7 @@ the relevant RFC's as well as actual practice in the field. However
cookielib.py is tighly integrated with urllib2 and it's not possible
to use most of the features of cookielib without simultaneously using
urllib2. Unfortunataely we only use httplib because of our dependency
-on xmlrpclib. Without urllib2 cookielib is a non-starter.
+on xmlrpc.client. Without urllib2 cookielib is a non-starter.
This module is a minimal implementation of Netscape cookies which
works equally well on either the client or server side. It's API is
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 9e710f955..960c9d5ea 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -31,7 +31,6 @@ import socket
import struct
from types import *
import re
-import xmlrpclib
import datetime
import netaddr
import time
diff --git a/ipapython/nsslib.py b/ipapython/nsslib.py
index da4521894..fbe607506 100644
--- a/ipapython/nsslib.py
+++ b/ipapython/nsslib.py
@@ -296,14 +296,14 @@ class NSSConnection(httplib.HTTPConnection, NSSAddressFamilyFallback):
raise e
class NSSHTTPS(httplib.HTTP):
- # We would like to use HTTP 1.1 not the older HTTP 1.0 but xmlrpclib
+ # We would like to use HTTP 1.1 not the older HTTP 1.0 but xmlrpc.client
# and httplib do not play well together. httplib when the protocol
- # is 1.1 will add a host header in the request. But xmlrpclib
+ # is 1.1 will add a host header in the request. But xmlrpc.client
# always adds a host header irregardless of the HTTP protocol
# version. That means the request ends up with 2 host headers,
# but Apache freaks out if it sees 2 host headers, a known Apache
# issue. httplib has a mechanism to skip adding the host header
- # (i.e. skip_host in HTTPConnection.putrequest()) but xmlrpclib
+ # (i.e. skip_host in HTTPConnection.putrequest()) but xmlrpc.client
# doesn't use it. Oh well, back to 1.0 :-(
#
#_http_vsn = 11
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 72c481df3..64620b4cc 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -24,7 +24,7 @@ Also see the `ipalib.rpc` module.
"""
from xml.sax.saxutils import escape
-from xmlrpclib import Fault
+from six.moves.xmlrpc_client import Fault
import os
import datetime
import json
diff --git a/ipatests/test_ipalib/test_parameters.py b/ipatests/test_ipalib/test_parameters.py
index 3f9b2f3ab..41c10fad4 100644
--- a/ipatests/test_ipalib/test_parameters.py
+++ b/ipatests/test_ipalib/test_parameters.py
@@ -31,7 +31,7 @@ import sys
from types import NoneType
from decimal import Decimal
from inspect import isclass
-from xmlrpclib import MAXINT, MININT
+from six.moves.xmlrpc_client import MAXINT, MININT
import six
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index 1d3f33add..f50f08a2b 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -22,7 +22,7 @@ Test the `ipalib.rpc` module.
"""
from __future__ import print_function
-from xmlrpclib import Binary, Fault, dumps, loads
+from six.moves.xmlrpc_client import Binary, Fault, dumps, loads
import nose
import six
@@ -58,10 +58,10 @@ def test_round_trip():
"""
Test `ipalib.rpc.xml_wrap` and `ipalib.rpc.xml_unwrap`.
- This tests the two functions together with ``xmlrpclib.dumps()`` and
- ``xmlrpclib.loads()`` in a full wrap/dumps/loads/unwrap round trip.
+ This tests the two functions together with ``xmlrpc.client.dumps()`` and
+ ``xmlrpc.client.loads()`` in a full wrap/dumps/loads/unwrap round trip.
"""
- # We first test that our assumptions about xmlrpclib module in the Python
+ # We first test that our assumptions about xmlrpc.client module in the Python
# standard library are correct:
assert_equal(dump_n_load(utf8_bytes), unicode_str)
assert_equal(dump_n_load(unicode_str), unicode_str)
@@ -75,9 +75,9 @@ def test_round_trip():
# Now we test our wrap and unwrap methods in combination with dumps, loads:
# All str should come back str (because they get wrapped in
- # xmlrpclib.Binary(). All unicode should come back unicode because str
+ # xmlrpc.client.Binary(). All unicode should come back unicode because str
# explicity get decoded by rpc.xml_unwrap() if they weren't already
- # decoded by xmlrpclib.loads().
+ # decoded by xmlrpc.client.loads().
assert_equal(round_trip(utf8_bytes), utf8_bytes)
assert_equal(round_trip(unicode_str), unicode_str)
assert_equal(round_trip(binary_bytes), binary_bytes)