Skip to content

Commit 98ec84e

Browse files
committed
cli: Fix cloe-launch prepare not showing output.
1 parent d914acd commit 98ec84e

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

cli/cloe_launch/exec.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def _prepare_virtualenv(self, with_json: bool = False) -> None:
335335
for arg in self.conan_args:
336336
conan_cmd.append(arg)
337337
conan_cmd.append(self.profile_path)
338-
result = subprocess.run(conan_cmd, check=False, capture_output=True)
338+
result = subprocess.run(conan_cmd, check=False, capture_output=self.capture_output)
339339
if result.returncode == 0:
340340
# Short-circuit out if everything is fine.
341341
return
@@ -349,7 +349,15 @@ def _prepare_virtualenv(self, with_json: bool = False) -> None:
349349
stderr_lines = result.stderr.decode().splitlines()
350350
for line in stderr_lines:
351351
logging.error(
352-
"\n".join(textwrap.wrap(line, 80, initial_indent=" ", subsequent_indent=" ", break_long_words=False))
352+
"\n".join(
353+
textwrap.wrap(
354+
line,
355+
80,
356+
initial_indent=" ",
357+
subsequent_indent=" ",
358+
break_long_words=False,
359+
)
360+
)
353361
)
354362

355363
# Here are some errors that can happen and what to do about them.
@@ -393,15 +401,14 @@ def _prepare_virtualenv(self, with_json: bool = False) -> None:
393401
],
394402
}
395403
for error in stderr_lines:
396-
for (regex, response) in known_errors.items():
404+
for regex, response in known_errors.items():
397405
if re.match(regex, error):
398406
logging.error("")
399407
logging.error("Note:")
400408
for line in response:
401409
logging.error(f" {line}")
402410
sys.exit(2)
403411

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

558+
# TODO: Use preserve_env from plugin_setups!
559+
551560
# Replace this process with the SHELL now.
552561
sys.stdout.flush()
553562
cmd = [shell]

cli/cloe_launch/procutils.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,19 @@ def get(self, key: str, default: Optional[str] = None) -> Optional[str]:
236236
def get_list(
237237
self, key: str, default: Optional[List[str]] = None
238238
) -> Optional[List[str]]:
239-
"""Get the value at key and split or return default."""
239+
"""Get the value at key and split or return default.
240+
241+
Note: The list may contain empty entries, as is the case when a trailing
242+
colon or sandwiched colon is present:
243+
244+
PATH=/bin:/usr/bin:
245+
PATH=:/bin:/usr/bin
246+
PATH=/bin::/usr/bin
247+
248+
In each of these these examples, an empty string is present in the list.
249+
These may be interpreted by the shell and many programs as the current directory.
250+
This has been experimentally verified with the PATH variable in Zsh and Bash.
251+
"""
240252
if key in self._data:
241253
return self._data[key].split(self._sep)
242254
return default

0 commit comments

Comments
 (0)