执行命令并输出日志,返回是否成功
(
cmd: list[str] | str, cwd: Path | str | None = None, shell: bool = False
)
| 131 | |
| 132 | |
| 133 | def 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 | |
| 148 | def update_submodules(skip_if_exist: bool = True) -> bool: |
no test coverage detected