diff --git a/examples/system/ota/advanced_https_ota/example_test.py b/examples/system/ota/advanced_https_ota/example_test.py index 0638595e56..2545f82955 100644 --- a/examples/system/ota/advanced_https_ota/example_test.py +++ b/examples/system/ota/advanced_https_ota/example_test.py @@ -1,8 +1,7 @@ import re import os import socket -import BaseHTTPServer -import SimpleHTTPServer +import http.server from threading import Thread import ssl @@ -99,7 +98,7 @@ def https_request_handler(): """ Returns a request handler class that handles broken pipe exception """ - class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + class RequestHandler(http.server.SimpleHTTPRequestHandler): def finish(self): try: if not self.wfile.closed: @@ -111,7 +110,7 @@ def https_request_handler(): def handle(self): try: - BaseHTTPServer.BaseHTTPRequestHandler.handle(self) + http.server.BaseHTTPRequestHandler.handle(self) except socket.error: pass @@ -121,8 +120,7 @@ def https_request_handler(): def start_https_server(ota_image_dir, server_ip, server_port): server_file, key_file = get_ca_cert(ota_image_dir) requestHandler = https_request_handler() - httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - requestHandler) + httpd = http.server.HTTPServer((server_ip, server_port), requestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file, @@ -140,7 +138,7 @@ def redirect_handler_factory(url): """ Returns a request handler class that redirects to supplied `url` """ - class RedirectHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + class RedirectHandler(http.server.SimpleHTTPRequestHandler): def do_GET(self): print("Sending resp, URL: " + url) self.send_response(301) @@ -149,7 +147,7 @@ def redirect_handler_factory(url): def handle(self): try: - BaseHTTPServer.BaseHTTPRequestHandler.handle(self) + http.server.BaseHTTPRequestHandler.handle(self) except socket.error: pass @@ -161,8 +159,7 @@ def start_redirect_server(ota_image_dir, server_ip, server_port, redirection_por server_file, key_file = get_ca_cert(ota_image_dir) redirectHandler = redirect_handler_factory("https://" + server_ip + ":" + str(redirection_port) + "/advanced_https_ota.bin") - httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - redirectHandler) + httpd = http.server.HTTPServer((server_ip, server_port), redirectHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file, diff --git a/examples/system/ota/native_ota_example/example_test.py b/examples/system/ota/native_ota_example/example_test.py index 68f8202277..9e486d063d 100644 --- a/examples/system/ota/native_ota_example/example_test.py +++ b/examples/system/ota/native_ota_example/example_test.py @@ -1,8 +1,7 @@ import re import os import socket -import BaseHTTPServer -import SimpleHTTPServer +import http.server from threading import Thread import ssl @@ -99,7 +98,7 @@ def https_request_handler(): """ Returns a request handler class that handles broken pipe exception """ - class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + class RequestHandler(http.server.SimpleHTTPRequestHandler): def finish(self): try: if not self.wfile.closed: @@ -111,7 +110,7 @@ def https_request_handler(): def handle(self): try: - BaseHTTPServer.BaseHTTPRequestHandler.handle(self) + http.server.BaseHTTPRequestHandler.handle(self) except socket.error: pass @@ -121,8 +120,7 @@ def https_request_handler(): def start_https_server(ota_image_dir, server_ip, server_port): server_file, key_file = get_ca_cert(ota_image_dir) requestHandler = https_request_handler() - httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - requestHandler) + httpd = http.server.HTTPServer((server_ip, server_port), requestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file, diff --git a/examples/system/ota/simple_ota_example/example_test.py b/examples/system/ota/simple_ota_example/example_test.py index ff1cea95b5..fd9adb4f98 100644 --- a/examples/system/ota/simple_ota_example/example_test.py +++ b/examples/system/ota/simple_ota_example/example_test.py @@ -1,8 +1,7 @@ import re import os import socket -import BaseHTTPServer -import SimpleHTTPServer +import http.server from threading import Thread import ssl @@ -86,8 +85,7 @@ def start_https_server(ota_image_dir, server_ip, server_port): key_file_handle.write(server_key) key_file_handle.close() - httpd = BaseHTTPServer.HTTPServer((server_ip, server_port), - SimpleHTTPServer.SimpleHTTPRequestHandler) + httpd = http.server.HTTPServer((server_ip, server_port), http.server.SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=key_file,