mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
Remove Python 2 leftovers.
Fixes: 1ca0323e7c29 ("Require Python 3 and remove support for Python 2.") Reported at: https://bugzilla.redhat.com/show_bug.cgi?id=1949875 Signed-off-by: Rosemarie O'Riorden <roriorde@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
parent
ad256c3140
commit
bd90524550
@ -7,8 +7,6 @@
|
|||||||
# notice and this notice are preserved. This file is offered as-is,
|
# notice and this notice are preserved. This file is offered as-is,
|
||||||
# without warranty of any kind.
|
# without warranty of any kind.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import getopt
|
import getopt
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#! @PYTHON3@
|
#! @PYTHON3@
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import getopt
|
import getopt
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
"""
|
"""
|
||||||
# pylint: disable=redefined-builtin, ungrouped-imports
|
# pylint: disable=redefined-builtin, ungrouped-imports
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from bisect import bisect_left, bisect_right, insort
|
from bisect import bisect_left, bisect_right, insort
|
||||||
from collections import Sequence, MutableSequence
|
from collections import Sequence, MutableSequence
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
@ -18,22 +18,14 @@ rpcserver is an XML RPC server that allows RPC client to initiate tests
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import exceptions
|
|
||||||
|
|
||||||
import xmlrpc.client
|
import xmlrpc.client
|
||||||
|
|
||||||
import tcp
|
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.error import CannotListenError
|
from twisted.internet.error import CannotListenError
|
||||||
from twisted.web import server
|
from twisted.web import server
|
||||||
from twisted.web import xmlrpc
|
from twisted.web import xmlrpc
|
||||||
|
|
||||||
import udp
|
from . import tcp, udp, util, vswitch
|
||||||
|
|
||||||
import util
|
|
||||||
|
|
||||||
import vswitch
|
|
||||||
|
|
||||||
|
|
||||||
class TestArena(xmlrpc.XMLRPC):
|
class TestArena(xmlrpc.XMLRPC):
|
||||||
@ -210,7 +202,7 @@ class TestArena(xmlrpc.XMLRPC):
|
|||||||
(_, port) = self.__get_handle_resources(handle)
|
(_, port) = self.__get_handle_resources(handle)
|
||||||
port.loseConnection()
|
port.loseConnection()
|
||||||
self.__delete_handle(handle)
|
self.__delete_handle(handle)
|
||||||
except exceptions.KeyError:
|
except KeyError:
|
||||||
return -1
|
return -1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -222,7 +214,7 @@ class TestArena(xmlrpc.XMLRPC):
|
|||||||
(_, connector) = self.__get_handle_resources(handle)
|
(_, connector) = self.__get_handle_resources(handle)
|
||||||
connector.disconnect()
|
connector.disconnect()
|
||||||
self.__delete_handle(handle)
|
self.__delete_handle(handle)
|
||||||
except exceptions.KeyError:
|
except KeyError:
|
||||||
return -1
|
return -1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import time
|
|||||||
from twisted.internet import interfaces
|
from twisted.internet import interfaces
|
||||||
from twisted.internet.protocol import ClientFactory, Factory, Protocol
|
from twisted.internet.protocol import ClientFactory, Factory, Protocol
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface.declarations import implementer
|
||||||
|
|
||||||
|
|
||||||
class TcpListenerConnection(Protocol):
|
class TcpListenerConnection(Protocol):
|
||||||
@ -55,8 +55,8 @@ class TcpListenerFactory(Factory):
|
|||||||
return str(self.stats)
|
return str(self.stats)
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(interfaces.IPushProducer)
|
||||||
class Producer(object):
|
class Producer(object):
|
||||||
implements(interfaces.IPushProducer)
|
|
||||||
"""
|
"""
|
||||||
This producer class generates infinite byte stream for a specified time
|
This producer class generates infinite byte stream for a specified time
|
||||||
duration
|
duration
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ import socket
|
|||||||
import struct
|
import struct
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import exceptions
|
|
||||||
|
|
||||||
import xmlrpc.client
|
import xmlrpc.client
|
||||||
|
|
||||||
|
|
||||||
@ -88,7 +86,7 @@ def start_process(args):
|
|||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
return (p.returncode, out, err)
|
return (p.returncode, out, err)
|
||||||
except exceptions.OSError:
|
except OSError:
|
||||||
return (-1, None, None)
|
return (-1, None, None)
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"""
|
"""
|
||||||
vswitch module allows its callers to interact with OVS DB.
|
vswitch module allows its callers to interact with OVS DB.
|
||||||
"""
|
"""
|
||||||
import util
|
from . import util
|
||||||
|
|
||||||
|
|
||||||
def ovs_vsctl_add_bridge(bridge):
|
def ovs_vsctl_add_bridge(bridge):
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from distutils.command.build_ext import build_ext
|
from distutils.command.build_ext import build_ext
|
||||||
@ -82,8 +80,6 @@ setup_args = dict(
|
|||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
'Topic :: System :: Networking',
|
'Topic :: System :: Networking',
|
||||||
'License :: OSI Approved :: Apache Software License',
|
'License :: OSI Approved :: Apache Software License',
|
||||||
'Programming Language :: Python :: 2',
|
|
||||||
'Programming Language :: Python :: 2.7',
|
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Programming Language :: Python :: 3.4',
|
'Programming Language :: Python :: 3.4',
|
||||||
'Programming Language :: Python :: 3.5',
|
'Programming Language :: Python :: 3.5',
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import email
|
import email
|
||||||
import getopt
|
import getopt
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
# ...
|
# ...
|
||||||
# ...
|
# ...
|
||||||
#
|
#
|
||||||
from __future__ import print_function
|
|
||||||
import gdb
|
import gdb
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
@ -19,7 +19,7 @@ achieved by tunneling the control connection inside the tunnel itself.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import xmlrpclib
|
import xmlrpc.client
|
||||||
|
|
||||||
import ovstest.args as args
|
import ovstest.args as args
|
||||||
import ovstest.tests as tests
|
import ovstest.tests as tests
|
||||||
@ -64,13 +64,13 @@ if __name__ == '__main__':
|
|||||||
ps = get_packet_sizes(me, he, args.client[0])
|
ps = get_packet_sizes(me, he, args.client[0])
|
||||||
tests.do_direct_tests(me, he, bandwidth, interval, ps)
|
tests.do_direct_tests(me, he, bandwidth, interval, ps)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "Terminating"
|
print("Terminating")
|
||||||
except xmlrpclib.Fault:
|
except xmlrpc.client.Fault:
|
||||||
print "Couldn't contact peer"
|
print("Couldn't contact peer")
|
||||||
except socket.error:
|
except socket.error:
|
||||||
print "Couldn't contact peer"
|
print("Couldn't contact peer")
|
||||||
except xmlrpclib.ProtocolError:
|
except xmlrpc.client.ProtocolError:
|
||||||
print "XMLRPC control channel was abruptly terminated"
|
print("XMLRPC control channel was abruptly terminated")
|
||||||
finally:
|
finally:
|
||||||
if local_server is not None:
|
if local_server is not None:
|
||||||
local_server.terminate()
|
local_server.terminate()
|
||||||
|
@ -70,7 +70,7 @@ result. Expected usage is for ovs-appctl backtrace to be piped in.""")
|
|||||||
if os.path.exists(debug):
|
if os.path.exists(debug):
|
||||||
binary = debug
|
binary = debug
|
||||||
|
|
||||||
print "Binary: %s\n" % binary
|
print("Binary: %s\n" % binary)
|
||||||
|
|
||||||
stdin = sys.stdin.read()
|
stdin = sys.stdin.read()
|
||||||
|
|
||||||
@ -88,15 +88,15 @@ result. Expected usage is for ovs-appctl backtrace to be piped in.""")
|
|||||||
for lines, count in traces:
|
for lines, count in traces:
|
||||||
longest = max(len(l) for l in lines)
|
longest = max(len(l) for l in lines)
|
||||||
|
|
||||||
print "Backtrace Count: %d" % count
|
print("Backtrace Count: %d" % count)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
match = re.search(r'\[(0x.*)]', line)
|
match = re.search(r'\[(0x.*)]', line)
|
||||||
if match:
|
if match:
|
||||||
print "%s %s" % (line.ljust(longest),
|
print("%s %s" % (line.ljust(longest),
|
||||||
addr2line(binary, match.group(1)))
|
addr2line(binary, match.group(1))))
|
||||||
else:
|
else:
|
||||||
print line
|
print(line)
|
||||||
print
|
print()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
import getopt
|
import getopt
|
||||||
import struct
|
import struct
|
||||||
@ -79,7 +77,7 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
|
options, args = getopt.gnu_getopt(sys.argv[1:], 'hV',
|
||||||
['help', 'version'])
|
['help', 'version'])
|
||||||
except getopt.GetoptException as geo:
|
except getopt.GetoptError as geo:
|
||||||
sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
|
sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import BaseHTTPServer
|
|
||||||
import getopt
|
import getopt
|
||||||
import httplib
|
import http.client
|
||||||
|
import http.server
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@ -84,7 +84,7 @@ class UDPReceiver:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
sock.bind((self.vlan_ip, self.vlan_port))
|
sock.bind((self.vlan_ip, self.vlan_port))
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
print_safe('Failed to bind to %s:%d with error: %s'
|
print_safe('Failed to bind to %s:%d with error: %s'
|
||||||
% (self.vlan_ip, self.vlan_port, e))
|
% (self.vlan_ip, self.vlan_port, e))
|
||||||
os._exit(1) #sys.exit only exits the current thread.
|
os._exit(1) #sys.exit only exits the current thread.
|
||||||
@ -95,7 +95,7 @@ class UDPReceiver:
|
|||||||
data, _ = sock.recvfrom(4096)
|
data, _ = sock.recvfrom(4096)
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
continue
|
continue
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
print_safe('Failed to receive from %s:%d with error: %s'
|
print_safe('Failed to receive from %s:%d with error: %s'
|
||||||
% (self.vlan_ip, self.vlan_port, e))
|
% (self.vlan_ip, self.vlan_port, e))
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
@ -180,7 +180,7 @@ class VlanServer:
|
|||||||
for _ in range(send_time * 2):
|
for _ in range(send_time * 2):
|
||||||
try:
|
try:
|
||||||
send_packet(test_id, size, ip, port)
|
send_packet(test_id, size, ip, port)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
self.set_result(test_id, 'Failure: ' + str(e))
|
self.set_result(test_id, 'Failure: ' + str(e))
|
||||||
return
|
return
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
@ -194,15 +194,15 @@ class VlanServer:
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.udp_recv.start()
|
self.udp_recv.start()
|
||||||
try:
|
try:
|
||||||
BaseHTTPServer.HTTPServer((self.server_ip, self.server_port),
|
http.server.HTTPServer((self.server_ip, self.server_port),
|
||||||
VlanServerHandler).serve_forever()
|
VlanServerHandler).serve_forever()
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
print_safe('Failed to start control server: %s' % e)
|
print_safe('Failed to start control server: %s' % e)
|
||||||
self.udp_recv.stop()
|
self.udp_recv.stop()
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
class VlanServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
class VlanServerHandler(http.server.BaseHTTPRequestHandler):
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
|
|
||||||
#Guarantee three arguments.
|
#Guarantee three arguments.
|
||||||
@ -244,7 +244,7 @@ class VlanClient:
|
|||||||
self.udp_recv = UDPReceiver(vlan_ip, vlan_port)
|
self.udp_recv = UDPReceiver(vlan_ip, vlan_port)
|
||||||
|
|
||||||
def request(self, resource):
|
def request(self, resource):
|
||||||
conn = httplib.HTTPConnection(self.server_ip_port)
|
conn = http.client.HTTPConnection(self.server_ip_port)
|
||||||
conn.request('GET', resource)
|
conn.request('GET', resource)
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ class VlanClient:
|
|||||||
try:
|
try:
|
||||||
conn = self.request('/start/recv')
|
conn = self.request('/start/recv')
|
||||||
data = conn.getresponse().read()
|
data = conn.getresponse().read()
|
||||||
except (socket.error, httplib.HTTPException), e:
|
except (socket.error, http.client.HTTPException) as e:
|
||||||
error_msg(e)
|
error_msg(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ class VlanClient:
|
|||||||
send_packet(test_id, size, ip, port)
|
send_packet(test_id, size, ip, port)
|
||||||
resp = self.request('/result/%d' % test_id).getresponse()
|
resp = self.request('/result/%d' % test_id).getresponse()
|
||||||
data = resp.read()
|
data = resp.read()
|
||||||
except (socket.error, httplib.HTTPException), e:
|
except (socket.error, http.client.HTTPException) as e:
|
||||||
error_msg(e)
|
error_msg(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ class VlanClient:
|
|||||||
try:
|
try:
|
||||||
conn = self.request(resource)
|
conn = self.request(resource)
|
||||||
test_id = conn.getresponse().read()
|
test_id = conn.getresponse().read()
|
||||||
except (socket.error, httplib.HTTPException), e:
|
except (socket.error, http.client.HTTPException) as e:
|
||||||
error_msg(e)
|
error_msg(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ class VlanClient:
|
|||||||
try:
|
try:
|
||||||
resp = self.request('/ping').getresponse()
|
resp = self.request('/ping').getresponse()
|
||||||
data = resp.read()
|
data = resp.read()
|
||||||
except (socket.error, httplib.HTTPException), e:
|
except (socket.error, http.client.HTTPException) as e:
|
||||||
error_msg(e)
|
error_msg(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ def main():
|
|||||||
try:
|
try:
|
||||||
options, args = getopt.gnu_getopt(sys.argv[1:], 'hVs',
|
options, args = getopt.gnu_getopt(sys.argv[1:], 'hVs',
|
||||||
['help', 'version', 'server'])
|
['help', 'version', 'server'])
|
||||||
except getopt.GetoptError, geo:
|
except getopt.GetoptError as geo:
|
||||||
print_safe('%s: %s\n' % (sys.argv[0], geo.msg))
|
print_safe('%s: %s\n' % (sys.argv[0], geo.msg))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user