Skip to content

Commit

Permalink
[execute_process] emulate_tty now configurable and defaults to true
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Stonier <[email protected]>
  • Loading branch information
stonier committed Jun 22, 2019
1 parent 563bb7f commit cda348b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion launch/launch/actions/execute_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import signal
import threading
import traceback
import yaml
from typing import Any # noqa: F401
from typing import Callable
from typing import cast
Expand Down Expand Up @@ -90,6 +91,7 @@ def __init__(
'sigterm_timeout', default=5),
sigkill_timeout: SomeSubstitutionsType = LaunchConfiguration(
'sigkill_timeout', default=5),
emulate_tty: bool = True,
prefix: Optional[SomeSubstitutionsType] = None,
output: Text = 'log',
output_format: Text = '[{this.name}] {line}',
Expand Down Expand Up @@ -168,6 +170,8 @@ def __init__(
as a string or a list of strings and Substitutions to be resolved
at runtime, defaults to the LaunchConfiguration called
'sigkill_timeout'
:param: emulate_tty emulate a tty (terminal), defaults to
the LaunchConfiguration called 'emulate_tty'
:param: prefix a set of commands/arguments to preceed the cmd, used for
things like gdb/valgrind and defaults to the LaunchConfiguration
called 'launch-prefix'
Expand Down Expand Up @@ -206,6 +210,7 @@ def __init__(
self.__shell = shell
self.__sigterm_timeout = normalize_to_list_of_substitutions(sigterm_timeout)
self.__sigkill_timeout = normalize_to_list_of_substitutions(sigkill_timeout)
self.__emulate_tty = emulate_tty
self.__prefix = normalize_to_list_of_substitutions(
LaunchConfiguration('launch-prefix', default='') if prefix is None else prefix
)
Expand Down Expand Up @@ -513,6 +518,16 @@ async def __execute_process(self, context: LaunchContext) -> None:
self.__logger.info("process details: cmd=[{}], cwd='{}', custom_env?={}".format(
', '.join(cmd), cwd, 'True' if env is not None else 'False'
))
try:
emulate_tty = yaml.safe_load(
context.launch_configurations['emulate_tty']
)
if type(emulate_tty) is not bool:
raise TypeError(
"emulate_tty is not boolean [{}]".format(type(emulate_tty))
)
except KeyError:
emulate_tty = self.__emulate_tty
try:
transport, self._subprocess_protocol = await async_execute_process(
lambda **kwargs: self.__ProcessProtocol(
Expand All @@ -522,7 +537,7 @@ async def __execute_process(self, context: LaunchContext) -> None:
cwd=cwd,
env=env,
shell=self.__shell,
emulate_tty=False,
emulate_tty=emulate_tty,
stderr_to_stdout=False,
)
except Exception:
Expand Down

0 comments on commit cda348b

Please sign in to comment.