diff options
author | Toshio Kuratomi <a.badger@gmail.com> | 2016-10-23 22:14:46 -0700 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-10-24 06:51:10 -0700 |
commit | 9d82a3aa0cca1a85687ee8490f9dbac6347bf5b5 (patch) | |
tree | f18b21a80307c6ea06299dba2272425a7cf73d78 | |
parent | fef9de30d952e76fe9e309f6213e12146c7bea68 (diff) | |
download | ansible-9d82a3aa0cca1a85687ee8490f9dbac6347bf5b5.tar.gz |
Fix the uri testserver to run on python3
(cherry picked from commit 589e71dbc5c9e7fd4bd83c6cbc6d8fab15f134f7)
-rw-r--r-- | test/integration/roles/test_uri/files/testserver.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/integration/roles/test_uri/files/testserver.py b/test/integration/roles/test_uri/files/testserver.py index d0d24a0050..1488c814af 100644 --- a/test/integration/roles/test_uri/files/testserver.py +++ b/test/integration/roles/test_uri/files/testserver.py @@ -1,7 +1,17 @@ -import mimetypes +import sys if __name__ == '__main__': - mimetypes.init() - mimetypes.add_type('application/json', '.json') - import SimpleHTTPServer - SimpleHTTPServer.test() + if sys.version_info[0] >= 3: + import http.server + import socketserver + PORT = int(sys.argv[1]) + Handler = http.server.SimpleHTTPRequestHandler + httpd = socketserver.TCPServer(("", PORT), Handler) + httpd.serve_forever() + else: + import mimetypes + mimetypes.init() + mimetypes.add_type('application/json', '.json') + import SimpleHTTPServer + SimpleHTTPServer.test() + |