Skip to content

Commit cfb8168

Browse files
hhansen-bdaiCopilotkellyguo11
authored
Adds improved readout from install_deps.py (isaac-sim#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: Hunter Hansen <50837800+hhansen-bdai@users.noreply.github.com> Signed-off-by: Kelly Guo <kellyg@nvidia.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kelly Guo <kellyg@nvidia.com>
1 parent bf711db commit cfb8168

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tools/install_deps.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import os
3232
import shutil
3333
import toml
34-
from subprocess import run
34+
from subprocess import PIPE, STDOUT, Popen
3535

3636
# add argparse arguments
3737
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"):
146146
def run_and_print(args: list[str]):
147147
"""Runs a subprocess and prints the output to stdout.
148148
149-
This function wraps subprocess.run() and prints the output to stdout.
149+
This function wraps Popen and prints the output to stdout in real-time.
150150
151151
Args:
152-
args: A list of arguments to pass to subprocess.run().
152+
args: A list of arguments to pass to Popen.
153153
"""
154-
completed_process = run(args=args, capture_output=True, check=True)
155-
print(f"{str(completed_process.stdout, encoding='utf-8')}")
154+
print(f'Running "{args}"')
155+
with Popen(args, stdout=PIPE, stderr=STDOUT, env=os.environ) as p:
156+
while p.poll() is None:
157+
text = p.stdout.read1().decode("utf-8")
158+
print(text, end="", flush=True)
159+
return_code = p.poll()
160+
if return_code != 0:
161+
raise RuntimeError(f'Subprocess with args: "{args}" failed. The returned error code was: {return_code}')
156162

157163

158164
def main():

0 commit comments

Comments
 (0)