Run a command and check for errors. Args: cmd (List[str]): The command to run as a list.
(
cmd: List[str], check=True, env: dict[str, str] | None = None
)
| 673 | |
| 674 | |
| 675 | def _run_cmd( |
| 676 | cmd: List[str], check=True, env: dict[str, str] | None = None |
| 677 | ) -> subprocess.CompletedProcess[bytes]: |
| 678 | """Run a command and check for errors. |
| 679 | |
| 680 | Args: |
| 681 | cmd (List[str]): The command to run as a list. |
| 682 | |
| 683 | """ |
| 684 | try: |
| 685 | result = subprocess.run( # nosec B603 - cmd constructed from trusted inputs |
| 686 | cmd, check=check, capture_output=True, env=env |
| 687 | ) |
| 688 | return result |
| 689 | except subprocess.CalledProcessError as e: |
| 690 | arg_string = " ".join(cmd) |
| 691 | raise RuntimeError( |
| 692 | f"Failed running command {arg_string}\nStderr: {e.stderr.decode()}\nStdout: {e.stdout.decode()}" |
| 693 | ) |
| 694 | |
| 695 | |
| 696 | # Name of an optional resource containing the `flatc` executable. |
no test coverage detected