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
commit3d659f138684902ffd074cb0de1a0cbde79ef5b9 (patch)
tree464f8bd8bf8bddf62b7ded46efe9dff3d8997028 /lib
parent98f3af78b58d33272664a3d2873be4fb5ea367b2 (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