Skip to content

Commit

Permalink
Use logging instead of print (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Nov 18, 2024
1 parent 404e82e commit 5b9596b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ ignore = [
"S605",
"S607",
"SIM117",
"T201",
"UP022"
]
select = ["ALL"]
Expand Down
12 changes: 8 additions & 4 deletions src/tox_extra/bindep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import logging
import os
import subprocess
import sys
Expand All @@ -12,6 +13,8 @@
from collections.abc import Iterable
from pathlib import Path

logger = logging.getLogger(__name__)


@cache
def check_bindep(path: Path, profiles: Iterable[str] | None = None) -> None:
Expand All @@ -32,12 +35,13 @@ def check_bindep(path: Path, profiles: Iterable[str] | None = None) -> None:
cwd=path,
)
if result.returncode:
print(
msg = (
f"Running '{' '.join(cmd)}' returned {result.returncode}, "
"likely missing system dependencies.",
"likely missing system dependencies."
)
if result.stdout:
print(result.stdout)
msg += "\nstdout:\n" + result.stdout
if result.stderr:
print(result.stderr, file=sys.stderr)
msg += "\nstderr:\n" + result.stderr
logger.error(msg)
raise SystemExit(result.returncode)

0 comments on commit 5b9596b

Please sign in to comment.