MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / run_cmd

Function run_cmd

mod/project/git/scripts/deploy.py:35–50  ·  view source on GitHub ↗

执行命令并返回输出

(cmd, cwd=None)

Source from the content-addressed store, hash-verified

33 DEPLOY_LOGS.append(separator)
34
35def 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
52def get_site_info(site_name):
53 """获取网站信息"""

Callers 4

execute_deploy_scriptFunction · 0.70
auto_deployFunction · 0.70
manual_branch_deployFunction · 0.70
manual_rollback_deployFunction · 0.70

Calls 3

logFunction · 0.70
runMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected