Skip to content

Commit

Permalink
🐛Fixes CLI hanging in commands calling 'make.exe' (#180)
Browse files Browse the repository at this point in the history
* Fixes PROS hanging on "pros make" with no toolchain

* Adds new "Subprocess" class. Logs errors and doesn't hang on exit.

* 🐛Fixes CLI hanging in make command

* Formats errors better. Uses error instead of warn.
  • Loading branch information
BennyBot authored Nov 19, 2021
1 parent cb3024f commit fcb3094
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions pros/conductor/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,17 @@ def make(self, build_args: List[str]):
make_cmd = 'make'
stdout_pipe = EchoPipe()
stderr_pipe = EchoPipe(err=True)
process = subprocess.Popen(executable=make_cmd, args=[make_cmd, *build_args], cwd=self.directory, env=env,
process=None
try:
process = subprocess.Popen(executable=make_cmd, args=[make_cmd, *build_args], cwd=self.directory, env=env,
stdout=stdout_pipe, stderr=stderr_pipe)
except Exception as e:
if not os.environ.get('PROS_TOOLCHAIN'):
ui.logger(__name__).warn("PROS toolchain not found! Please ensure the toolchain is installed correctly and your environment variables are set properly.\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}.exe' WITH EXCEPTION: {str(e)}\n")
stdout_pipe.close()
stderr_pipe.close()
sys.exit()
stdout_pipe.close()
stderr_pipe.close()
process.wait()
Expand Down Expand Up @@ -275,7 +284,16 @@ def libscanbuild_capture(args: argparse.Namespace) -> Tuple[int, Iterable[Compil
else:
pipe = subprocess.DEVNULL
logger(__name__).debug(self.directory)
exit_code = run_build(args.build, env=environment, stdout=pipe, stderr=pipe, cwd=self.directory)
exit_code=None
try:
exit_code = run_build(args.build, env=environment, stdout=pipe, stderr=pipe, cwd=self.directory)
except Exception as e:
if not os.environ.get('PROS_TOOLCHAIN'):
ui.logger(__name__).warn("PROS toolchain not found! Please ensure the toolchain is installed correctly and your environment variables are set properly.\n")
ui.logger(__name__).error(f"ERROR WHILE CALLING '{make_cmd}.exe' WITH EXCEPTION: {str(e)}\n")
if not suppress_output:
pipe.close()
sys.exit()
if not suppress_output:
pipe.close()
# read the intercepted exec calls
Expand Down

0 comments on commit fcb3094

Please sign in to comment.