mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
example_test.py: Update OTA example tests to make it compatible with python3
This commit is contained in:
parent
b8f5d2e466
commit
c287ca1363
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user