mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
test-l7.py: Tidy up and python3-ify.
Haul test-l7.py into the 202nd decade by supporting python3. TFTPY still doesn't support python3, so work around this by handling import syntax errors so that even if tftpy is installed in a python3 environment, test-l7.py will not throw an exception while attempting to load it. Signed-off-by: Joe Stringer <joe@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
parent
40c7b2fc0d
commit
a27b51e97f
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2015, 2016 Nicira, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -15,9 +16,13 @@
|
||||
import argparse
|
||||
import socket
|
||||
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from SocketServer import TCPServer
|
||||
try: # Python 2.7
|
||||
from BaseHTTPServer import HTTPServer
|
||||
from SimpleHTTPServer import SimpleHTTPRequestHandler
|
||||
from SocketServer import TCPServer
|
||||
except:
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
from socketserver import TCPServer
|
||||
|
||||
|
||||
class TCPServerV6(HTTPServer):
|
||||
@ -62,7 +67,7 @@ def get_tftpd():
|
||||
def serve_forever(self):
|
||||
self.listen(self.ip, self.port)
|
||||
server = [OVSTFTPServer, None, TftpShared.DEF_TFTP_PORT]
|
||||
except ImportError:
|
||||
except (ImportError, SyntaxError):
|
||||
server = None
|
||||
pass
|
||||
return server
|
||||
@ -78,9 +83,9 @@ def main():
|
||||
|
||||
protocols = [srv for srv in SERVERS if SERVERS[srv] is not None]
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Run basic application servers.')
|
||||
description='Run basic application servers.')
|
||||
parser.add_argument('proto', default='http', nargs='?',
|
||||
help='protocol to serve (%s)' % protocols)
|
||||
help='protocol to serve (%s)' % protocols)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.proto not in protocols:
|
||||
|
Loading…
x
Reference in New Issue
Block a user