🩹 添加运行脚本环境变量设置

- 确保输出编码为utf-8,避免编码问题
This commit is contained in:
Cp0204 2024-11-12 11:39:22 +08:00
parent becaef7f19
commit abc5ef4e40

View File

@ -179,12 +179,18 @@ def run_script_now():
)
def generate_output():
# 设置环境变量
process_env = os.environ.copy()
process_env["PYTHONIOENCODING"] = "utf-8"
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True,
encoding="utf-8",
errors="replace",
bufsize=1,
env=process_env,
)
try:
for line in iter(process.stdout.readline, ""):