Skip to content

Commit

Permalink
cli: Fix cloe-launch prepare not showing output.
Browse files Browse the repository at this point in the history
  • Loading branch information
cassava committed Apr 22, 2024
1 parent a8a3b82 commit 740b6fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
17 changes: 13 additions & 4 deletions cli/cloe_launch/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def _prepare_virtualenv(self, with_json: bool = False) -> None:
for arg in self.conan_args:
conan_cmd.append(arg)
conan_cmd.append(self.profile_path)
result = subprocess.run(conan_cmd, check=False, capture_output=True)
result = subprocess.run(conan_cmd, check=False, capture_output=self.capture_output)
if result.returncode == 0:
# Short-circuit out if everything is fine.
return
Expand All @@ -349,7 +349,15 @@ def _prepare_virtualenv(self, with_json: bool = False) -> None:
stderr_lines = result.stderr.decode().splitlines()
for line in stderr_lines:
logging.error(
"\n".join(textwrap.wrap(line, 80, initial_indent=" ", subsequent_indent=" ", break_long_words=False))
"\n".join(
textwrap.wrap(
line,
80,
initial_indent=" ",
subsequent_indent=" ",
break_long_words=False,
)
)
)

# Here are some errors that can happen and what to do about them.
Expand Down Expand Up @@ -393,15 +401,14 @@ def _prepare_virtualenv(self, with_json: bool = False) -> None:
],
}
for error in stderr_lines:
for (regex, response) in known_errors.items():
for regex, response in known_errors.items():
if re.match(regex, error):
logging.error("")
logging.error("Note:")
for line in response:
logging.error(f" {line}")
sys.exit(2)


def _extract_engine_path(self, env: Environment) -> Path:
"""Return the first cloe-engine we find in the PATH."""
for bindir in env.get_list("PATH", default=[]):
Expand Down Expand Up @@ -548,6 +555,8 @@ def shell(
for plugin in plugin_setups:
logging.warning(f" {plugin.plugin}")

# TODO: Use preserve_env from plugin_setups!

# Replace this process with the SHELL now.
sys.stdout.flush()
cmd = [shell]
Expand Down
14 changes: 13 additions & 1 deletion cli/cloe_launch/procutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,19 @@ def get(self, key: str, default: Optional[str] = None) -> Optional[str]:
def get_list(
self, key: str, default: Optional[List[str]] = None
) -> Optional[List[str]]:
"""Get the value at key and split or return default."""
"""Get the value at key and split or return default.
Note: The list may contain empty entries, as is the case when a trailing
colon or sandwiched colon is present:
PATH=/bin:/usr/bin:
PATH=:/bin:/usr/bin
PATH=/bin::/usr/bin
In each of these these examples, an empty string is present in the list.
These may be interpreted by the shell and many programs as the current directory.
This has been experimentally verified with the PATH variable in Zsh and Bash.
"""
if key in self._data:
return self._data[key].split(self._sep)
return default
Expand Down

0 comments on commit 740b6fd

Please sign in to comment.