Skip to content

Adds improved readout from install_deps.py #3104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 8, 2025
16 changes: 11 additions & 5 deletions tools/install_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import os
import shutil
import toml
from subprocess import run
from subprocess import PIPE, STDOUT, Popen

# add argparse arguments
parser = argparse.ArgumentParser(description="A utility to install dependencies based on extension.toml files.")
Expand Down Expand Up @@ -146,13 +146,19 @@ def install_rosdep_packages(paths: list[str], ros_distro: str = "humble"):
def run_and_print(args: list[str]):
"""Runs a subprocess and prints the output to stdout.

This function wraps subprocess.run() and prints the output to stdout.
This function wraps Popen and prints the output to stdout in real-time.

Args:
args: A list of arguments to pass to subprocess.run().
args: A list of arguments to pass to Popen.
"""
completed_process = run(args=args, capture_output=True, check=True)
print(f"{str(completed_process.stdout, encoding='utf-8')}")
print(f'Running "{args}"')
with Popen(args, stdout=PIPE, stderr=STDOUT, env=os.environ) as p:
while p.poll() is None:
text = p.stdout.read1().decode("utf-8")
print(text, end="", flush=True)
return_code = p.poll()
if return_code != 0:
raise RuntimeError(f'Subprocess with args: "{args}" failed. The returned error code was: {return_code}')


def main():
Expand Down
Loading