summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu@debian.org>2020-07-16 14:25:39 +0200
committerEmilio Pozuelo Monfort <pochu@debian.org>2020-07-29 10:20:41 +0200
commit9cf234d40ec81f47fc6417cf1a507f2cc0f43058 (patch)
tree6ddca90111776da11de3cff26a2a59a8011c6e54 /lib
parentdc100e78cfed7f722ee8320d22ff23a41780250e (diff)
web_support.py: adapt HTTPServer imports for python3
Diffstat (limited to 'lib')
-rw-r--r--lib/python/web_support.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/python/web_support.py b/lib/python/web_support.py
index ebbf031944..334b36efe5 100644
--- a/lib/python/web_support.py
+++ b/lib/python/web_support.py
@@ -25,8 +25,13 @@ import grp
import traceback
import urllib
import threading
-import SocketServer
-import BaseHTTPServer
+
+try:
+ from SocketServer import ThreadingMixIn
+ from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
+except ImportError:
+ from socketserver import ThreadingMixIn
+ from http.server import HTTPServer, BaseHTTPRequestHandler
try:
from cStringIO import StringIO
@@ -779,8 +784,7 @@ class WebService(Service, WebServiceBase):
assert isinstance(r, Result), repr(r)
r.flatten(result.write)
-class ThreadingHTTPServer(SocketServer.ThreadingMixIn,
- BaseHTTPServer.HTTPServer):
+class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
RE_BASE_URL = re.compile(r'^(https?)://([^/]+)(.*)')
@@ -794,7 +798,7 @@ class WebServiceHTTP(WebServiceBase):
self.__parse_base_url(base_url)
service_self = self
- class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
+ class Handler(BaseHTTPRequestHandler):
def do_GET(self):
(method, path, remaining, params) = self.route()
if path is None:

© 2014-2024 Faster IT GmbH | imprint | privacy policy