Run a zccache fingerprint CLI command. Tries the daemon-backed ``zccache fp`` first (<1ms on cache hit). Falls back to standalone ``zccache-fp`` if the daemon is unavailable. Args: args: Arguments after ``fp`` / the binary name. check: If True, raise on non-zero exit.
(
args: list[str], *, check: bool = False, timeout: float = 60.0
)
| 342 | |
| 343 | |
| 344 | def _run_zccache( |
| 345 | args: list[str], *, check: bool = False, timeout: float = 60.0 |
| 346 | ) -> subprocess.CompletedProcess[str]: |
| 347 | """Run a zccache fingerprint CLI command. |
| 348 | |
| 349 | Tries the daemon-backed ``zccache fp`` first (<1ms on cache hit). |
| 350 | Falls back to standalone ``zccache-fp`` if the daemon is unavailable. |
| 351 | |
| 352 | Args: |
| 353 | args: Arguments after ``fp`` / the binary name. |
| 354 | check: If True, raise on non-zero exit. |
| 355 | timeout: Subprocess timeout in seconds. |
| 356 | |
| 357 | Returns: |
| 358 | CompletedProcess with captured stdout/stderr. |
| 359 | """ |
| 360 | # Try daemon-backed path first: ``zccache fp <args>`` |
| 361 | zccache_bin = _find_zccache() |
| 362 | if zccache_bin: |
| 363 | cmd = [zccache_bin, "fp"] + args |
| 364 | result = subprocess.run( |
| 365 | cmd, |
| 366 | capture_output=True, |
| 367 | text=True, |
| 368 | check=False, |
| 369 | timeout=timeout, |
| 370 | ) |
| 371 | # exit 0 (run) or 1 (skip) are valid; exit 2+ means daemon error |
| 372 | if result.returncode in (0, 1): |
| 373 | if check and result.returncode not in (0, 1): |
| 374 | raise subprocess.CalledProcessError( |
| 375 | result.returncode, cmd, result.stdout, result.stderr |
| 376 | ) |
| 377 | return result |
| 378 | |
| 379 | # Fallback to standalone: ``zccache-fp <args>`` |
| 380 | cmd = [_find_zccache_fp()] + args |
| 381 | return subprocess.run( |
| 382 | cmd, |
| 383 | capture_output=True, |
| 384 | text=True, |
| 385 | check=check, |
| 386 | timeout=timeout, |
| 387 | ) |
| 388 | |
| 389 | |
| 390 | # ============================================================================== |
no test coverage detected