From patchwork Mon Dec 21 20:47:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Bryant X-Patchwork-Id: 559709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 3E2F5140BB5 for ; Tue, 22 Dec 2015 07:50:21 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 938FA1069C; Mon, 21 Dec 2015 12:48:20 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id C8B9D1068B for ; Mon, 21 Dec 2015 12:48:18 -0800 (PST) Received: from bar2.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 56B951E00E1 for ; Mon, 21 Dec 2015 13:48:18 -0700 (MST) X-ASG-Debug-ID: 1450730897-03dc53742109d30001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id voBSZfWqEw16wPGM (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 21 Dec 2015 13:48:17 -0700 (MST) X-Barracuda-Envelope-From: russell@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 21 Dec 2015 20:48:17 -0000 Received-SPF: neutral (mx1-pf2.cudamail.com: 209.132.183.28 is neither permitted nor denied by SPF record at ovn.org) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id E78BA8E229; Mon, 21 Dec 2015 20:48:16 +0000 (UTC) Received: from x1c.redhat.com ([10.3.112.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBLKm0da002018; Mon, 21 Dec 2015 15:48:16 -0500 X-CudaMail-Envelope-Sender: russell@ovn.org From: Russell Bryant To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1220082785 X-CudaMail-DTE: 122115 X-CudaMail-Originating-IP: 209.132.183.28 Date: Mon, 21 Dec 2015 15:47:13 -0500 X-ASG-Orig-Subj: [##CM-E2-1220082785##][PATCH 13/55] python: Fix xmlrpclib imports. Message-Id: <1450730875-18083-14-git-send-email-russell@ovn.org> In-Reply-To: <1450730875-18083-1-git-send-email-russell@ovn.org> References: <1450730875-18083-1-git-send-email-russell@ovn.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1450730897 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 13/55] python: Fix xmlrpclib imports. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Fix imports of xmlrpclib to be compatible with Python 3. Python 2 had xmlrpclib (client) and SimpleXMLRPCServer (server). In Python 3, these have been renamed to xmlrpc.client and xmlrpc.server. The solution implemented here is to use the six library. It may seem excessive for this particular issue, but the six library provides helpers for Python 2 and 3 compatibility for many different issues. This is just the first of many uses of the six library. Signed-off-by: Russell Bryant --- INSTALL.md | 2 +- m4/openvswitch.m4 | 6 ++++++ python/ovstest/rpcserver.py | 5 +++-- python/ovstest/util.py | 5 +++-- python/requirements.txt | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 906825a..81c1ba1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ you will need the following software: privileges. If libcap-ng is installed, then Open vSwitch will automatically build with support for it. - - Python 2.7. + - Python 2.7. You must also have the Python six library. On Linux, you may choose to compile the kernel module that comes with the Open vSwitch distribution or to use the kernel module built into diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4 index 0cfaae6..de8abd5 100644 --- a/m4/openvswitch.m4 +++ b/m4/openvswitch.m4 @@ -341,6 +341,12 @@ else: fi done done + if test $ovs_cv_python != no; then + if test -x "$ovs_cv_python" && ! "$ovs_cv_python" -c 'import six' >/dev/null 2>&1; then + ovs_cv_python=no + AC_MSG_WARN([Missing Python six library.]) + fi + fi fi]) AC_SUBST([HAVE_PYTHON]) AM_MISSING_PROG([PYTHON], [python]) diff --git a/python/ovstest/rpcserver.py b/python/ovstest/rpcserver.py index 434344e..0264b67 100644 --- a/python/ovstest/rpcserver.py +++ b/python/ovstest/rpcserver.py @@ -20,8 +20,8 @@ from __future__ import print_function import exceptions import sys -import xmlrpclib +import six.moves.xmlrpc_client from twisted.internet import reactor from twisted.internet.error import CannotListenError from twisted.web import xmlrpc @@ -108,7 +108,8 @@ class TestArena(xmlrpc.XMLRPC): Returns the ovs-test server IP address that the other ovs-test server with the given ip will see. """ - server1 = xmlrpclib.Server("http://%s:%u/" % (his_ip, his_port)) + server1 = six.moves.xmlrpc_client.Server("http://%s:%u/" % + (his_ip, his_port)) return server1.get_my_address() def xmlrpc_create_udp_listener(self, port): diff --git a/python/ovstest/util.py b/python/ovstest/util.py index 16c012e..3b9d835 100644 --- a/python/ovstest/util.py +++ b/python/ovstest/util.py @@ -23,9 +23,9 @@ import select import socket import struct import signal +import six.moves.xmlrpc_client import subprocess import re -import xmlrpclib def str_ip(ip_address): @@ -167,7 +167,8 @@ def get_interface_from_routing_decision(ip): def rpc_client(ip, port): - return xmlrpclib.Server("http://%s:%u/" % (ip, port), allow_none=True) + return six.moves.xmlrpc_client.Server("http://%s:%u/" % (ip, port), + allow_none=True) def sigint_intercept(): diff --git a/python/requirements.txt b/python/requirements.txt index e7c0136..5c6907b 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1 +1,2 @@ # runtime dependencies +six