mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-16 04:22:22 +00:00
feat(tools): Enforce utf-8 encoding with open() function
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
@@ -22,7 +21,7 @@ def get_sdk_path() -> str:
|
||||
class CustomProcess(object):
|
||||
def __init__(self, cmd: str, logfile: str, verbose:bool =True) -> None:
|
||||
self.verbose = verbose
|
||||
self.f = open(logfile, 'w')
|
||||
self.f = open(logfile, 'w', encoding='utf-8')
|
||||
if self.verbose:
|
||||
logging.info('Starting {} > {}'.format(cmd, self.f.name))
|
||||
self.pexpect_proc = pexpect.spawn(cmd, timeout=60, logfile=self.f, encoding='utf-8', codec_errors='ignore')
|
||||
|
||||
@@ -132,7 +132,7 @@ def test_examples_protocol_https_server_simple(dut: Dut) -> None:
|
||||
ssl_context.check_hostname = False
|
||||
ssl_context.load_verify_locations(cadata=server_cert_pem)
|
||||
|
||||
with open(CLIENT_CERT_FILE, 'w') as cert, open(CLIENT_KEY_FILE, 'w') as key:
|
||||
with open(CLIENT_CERT_FILE, 'w', encoding='utf-8') as cert, open(CLIENT_KEY_FILE, 'w', encoding='utf-8') as key:
|
||||
cert.write(client_cert_pem)
|
||||
key.write(client_key_pem)
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import ssl
|
||||
import sys
|
||||
from threading import Event, Thread
|
||||
from threading import Event
|
||||
from threading import Thread
|
||||
|
||||
import paho.mqtt.client as mqtt
|
||||
import pexpect
|
||||
@@ -47,7 +48,7 @@ def on_message(client, userdata, msg): # type: (mqtt.Client, tuple, mqtt.client
|
||||
event_client_received_binary.set()
|
||||
return
|
||||
recv_binary = binary + '.received'
|
||||
with open(recv_binary, 'w') as fw:
|
||||
with open(recv_binary, 'w', encoding='utf-8') as fw:
|
||||
fw.write(msg.payload)
|
||||
raise ValueError('Received binary (saved as: {}) does not match the original file: {}'.format(recv_binary, binary))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user