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
commit75b2a557a7eb282dcea4b090062fc572f2bc9634 (patch)
tree9d299bd891259a068485bde800742bbb681820b6 /lib
parent2559a8f671c156db3ccd18972e6e6ad9d75c8077 (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