(command: list[str], fail_on_error: bool = True)
| 66 | |
| 67 | |
| 68 | def execute(command: list[str], fail_on_error: bool = True) -> tuple[str, str, int]: |
| 69 | proc = subprocess.Popen( |
| 70 | " ".join(command), stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True |
| 71 | ) |
| 72 | stdout_bytes, stderr_bytes = proc.communicate() |
| 73 | stdout, stderr = stdout_bytes.decode("utf-8"), stderr_bytes.decode("utf-8") |
| 74 | if fail_on_error and proc.returncode != 0: |
| 75 | print("EXECUTED COMMAND:", repr(command)) |
| 76 | print("RETURN CODE:", proc.returncode) |
| 77 | print() |
| 78 | print("STDOUT:") |
| 79 | print_offset(stdout) |
| 80 | print("STDERR:") |
| 81 | print_offset(stderr) |
| 82 | raise RuntimeError("Unexpected error from external tool.") |
| 83 | return stdout, stderr, proc.returncode |
| 84 | |
| 85 | |
| 86 | def ensure_environment_is_ready(mypy_path: str, temp_repo_path: str, mypy_cache_path: str) -> None: |
searching dependent graphs…