Unverified Commit 538b649b authored by Hunter Hansen's avatar Hunter Hansen Committed by GitHub

Adds improved readout from install_deps.py (#3104)

# Description
This adds improved readout from the subprocesses in `install_deps.py`.
It will now print the output instead of printing everything at once when
the process is finished. It also has improved error handling. This will
help users to have a better understanding of their build process and
more easily resolve issues.

## Type of change

<!-- As you go through the list, delete the ones that are not
applicable. -->

- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------
Signed-off-by: 's avatarHunter Hansen <50837800+hhansen-bdai@users.noreply.github.com>
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarCopilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent b3a59da3
...@@ -31,7 +31,7 @@ import argparse ...@@ -31,7 +31,7 @@ import argparse
import os import os
import shutil import shutil
import toml import toml
from subprocess import run from subprocess import PIPE, STDOUT, Popen
# add argparse arguments # add argparse arguments
parser = argparse.ArgumentParser(description="A utility to install dependencies based on extension.toml files.") parser = argparse.ArgumentParser(description="A utility to install dependencies based on extension.toml files.")
...@@ -146,13 +146,19 @@ def install_rosdep_packages(paths: list[str], ros_distro: str = "humble"): ...@@ -146,13 +146,19 @@ def install_rosdep_packages(paths: list[str], ros_distro: str = "humble"):
def run_and_print(args: list[str]): def run_and_print(args: list[str]):
"""Runs a subprocess and prints the output to stdout. """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:
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'Running "{args}"')
print(f"{str(completed_process.stdout, encoding='utf-8')}") 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(): def main():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment