Execute a command. If 'quiet' is true, then redirect stdout and stderr to a temporary file.
(command, *, context=None, quiet=False, **kwargs)
| 130 | |
| 131 | |
| 132 | def call(command, *, context=None, quiet=False, **kwargs): |
| 133 | """Execute a command. |
| 134 | |
| 135 | If 'quiet' is true, then redirect stdout and stderr to a temporary file. |
| 136 | """ |
| 137 | if context is not None: |
| 138 | quiet = context.quiet |
| 139 | |
| 140 | log("❯", " ".join(map(str, command)), spacing=" ") |
| 141 | if not quiet: |
| 142 | stdout = None |
| 143 | stderr = None |
| 144 | else: |
| 145 | if (logdir := getattr(context, "logdir", None)) is None: |
| 146 | logdir = pathlib.Path(tempfile.gettempdir()) |
| 147 | stdout = tempfile.NamedTemporaryFile( |
| 148 | "w", |
| 149 | encoding="utf-8", |
| 150 | delete=False, |
| 151 | dir=logdir, |
| 152 | prefix="cpython-wasi-", |
| 153 | suffix=".log", |
| 154 | ) |
| 155 | stderr = subprocess.STDOUT |
| 156 | log("📝", f"Logging output to {stdout.name} (--quiet)...") |
| 157 | |
| 158 | subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr) |
| 159 | |
| 160 | |
| 161 | def build_python_path(): |
no test coverage detected
searching dependent graphs…