执行命令并返回输出
(cmd, cwd=None)
| 33 | DEPLOY_LOGS.append(separator) |
| 34 | |
| 35 | def run_cmd(cmd, cwd=None): |
| 36 | """执行命令并返回输出""" |
| 37 | cmd = f'bash -l -c \'{cmd}\'' |
| 38 | try: |
| 39 | result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True, env=env) |
| 40 | if result.stdout: |
| 41 | print(result.stdout.strip()) |
| 42 | DEPLOY_LOGS.append(result.stdout.strip()) |
| 43 | if result.stderr: |
| 44 | print(result.stderr.strip()) |
| 45 | DEPLOY_LOGS.append(result.stderr.strip()) |
| 46 | return result.returncode == 0 |
| 47 | except Exception as e: |
| 48 | error_msg = f"命令执行失败: {str(e)}" |
| 49 | log(error_msg, "❌") |
| 50 | return False |
| 51 | |
| 52 | def get_site_info(site_name): |
| 53 | """获取网站信息""" |
no test coverage detected