MCPcopy
hub / github.com/MaaEnd/MaaEnd / run_command

Function run_command

tools/setup_workspace.py:133–145  ·  view source on GitHub ↗

执行命令并输出日志,返回是否成功

(
    cmd: list[str] | str, cwd: Path | str | None = None, shell: bool = False
)

Source from the content-addressed store, hash-verified

131
132
133def run_command(
134 cmd: list[str] | str, cwd: Path | str | None = None, shell: bool = False
135) -> bool:
136 """执行命令并输出日志,返回是否成功"""
137 cmd_str = " ".join(cmd) if isinstance(cmd, list) else str(cmd)
138 print(f"{Console.info(t('cmd_prefix'))} {cmd_str}")
139 try:
140 subprocess.check_call(cmd, cwd=cwd or PROJECT_BASE, shell=shell)
141 print(Console.ok(t("inf_command_success", cmd=cmd_str)))
142 return True
143 except subprocess.CalledProcessError as e:
144 print(Console.err(t("err_command_failed", cmd=cmd_str, error=e)))
145 return False
146
147
148def update_submodules(skip_if_exist: bool = True) -> bool:

Callers 3

update_submodulesFunction · 0.85
bootstrap_maadepsFunction · 0.85
run_build_scriptFunction · 0.85

Calls 4

infoMethod · 0.80
okMethod · 0.80
errMethod · 0.80
tFunction · 0.70

Tested by

no test coverage detected