diff --git a/deploy.py b/deploy.py index 554ecf3..c8f4941 100644 --- a/deploy.py +++ b/deploy.py @@ -82,17 +82,20 @@ def log_section(msg): def run_command(cmd, cwd=None, timeout=120, capture=True): """执行本地命令""" + # 设置 PYTHONUNBUFFERED=1 确保 Python 子进程不缓冲 stdout + env = os.environ.copy() + env['PYTHONUNBUFFERED'] = '1' try: if capture: result = subprocess.run( - cmd, shell=True, cwd=cwd, + cmd, shell=True, cwd=cwd, env=env, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=timeout ) return result.returncode == 0, result.stdout.strip(), result.stderr.strip() else: result = subprocess.run( - cmd, shell=True, cwd=cwd, timeout=timeout + cmd, shell=True, cwd=cwd, env=env, timeout=timeout ) return result.returncode == 0, "", "" except subprocess.TimeoutExpired: