Index: tools/scan-view/share/ScanView.py =================================================================== --- tools/scan-view/share/ScanView.py +++ tools/scan-view/share/ScanView.py @@ -1,6 +1,9 @@ -import BaseHTTPServer -import SimpleHTTPServer from __future__ import print_function +try: + from http.server import HTTPServer, SimpleHTTPRequestHandler +except ImportError: + from BaseHTTPServer import HTTPServer + from SimpleHTTPServer import SimpleHTTPRequestHandler import os import sys try: @@ -122,9 +125,9 @@ print('', file=s) self.status = s.getvalue() -class ScanViewServer(BaseHTTPServer.HTTPServer): +class ScanViewServer(HTTPServer): def __init__(self, address, handler, root, reporters, options): - BaseHTTPServer.HTTPServer.__init__(self, address, handler) + HTTPServer.__init__(self, address, handler) self.root = root self.reporters = reporters self.options = options @@ -180,7 +183,7 @@ if self.options.autoReload: import ScanView self.RequestHandlerClass = reload(ScanView).ScanViewRequestHandler - BaseHTTPServer.HTTPServer.finish_request(self, request, client_address) + HTTPServer.finish_request(self, request, client_address) def handle_error(self, request, client_address): # Ignore socket errors @@ -189,7 +192,7 @@ if self.options.debug > 1: print("%s: SERVER: ignored socket error." % (sys.argv[0],), file=sys.stderr) return - BaseHTTPServer.HTTPServer.handle_error(self, request, client_address) + HTTPServer.handle_error(self, request, client_address) # Borrowed from Quixote, with simplifications. def parse_query(qs, fields=None): @@ -210,19 +213,19 @@ item.append(value) return fields -class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): +class ScanViewRequestHandler(SimpleHTTPRequestHandler): server_version = "ScanViewServer/" + __version__ dynamic_mtime = time.time() def do_HEAD(self): try: - SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self) + SimpleHTTPRequestHandler.do_HEAD(self) except Exception as e: self.handle_exception(e) def do_GET(self): try: - SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) + SimpleHTTPRequestHandler.do_GET(self) except Exception as e: self.handle_exception(e)