Skip to content

Commit

Permalink
Log errors in subprocesses
Browse files Browse the repository at this point in the history
  • Loading branch information
WillB97 committed Nov 18, 2024
1 parent 8b2433d commit fa4c0c3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import shutil
import sys
from pathlib import Path
from subprocess import run
from subprocess import SubprocessError, check_call
from venv import create

logging.basicConfig(level=logging.INFO, format="[%(asctime)s] %(levelname)s: %(message)s")
Expand Down Expand Up @@ -86,11 +86,11 @@ def populate_python_config(runtime_ini: Path, venv_python: Path) -> None:
else:
pip = venv_dir / "bin/pip"
venv_python = venv_dir / "bin/python"
run(
check_call(
[str(venv_python), "-m", "pip", "install", "--upgrade", "pip", "setuptools", "wheel"],
cwd=venv_dir,
)
run([str(pip), "install", "-r", str(requirements)], cwd=venv_dir)
check_call([str(pip), "install", "-r", str(requirements)], cwd=venv_dir)

logger.info("Setting up Webots Python location")

Expand All @@ -106,6 +106,9 @@ def populate_python_config(runtime_ini: Path, venv_python: Path) -> None:
logger.info("Repopulating zone 0 with example code")
zone_0.mkdir(exist_ok=True)
shutil.copy(project_root / "example_robots/basic_robot.py", zone_0 / "robot.py")
except SubprocessError:
logger.error("Setup failed due to an error.")
input("An error occurred, press enter to close.")
except Exception:
logger.exception("Setup failed due to an error.")
input("An error occurred, press enter to close.")
Expand Down

0 comments on commit fa4c0c3

Please sign in to comment.