Skip to content

Commit 8006dfa

Browse files
Khush-devhidmic
andauthored
'output' is expanded as a substitution in XML/YAML files (#577)
* 'output' is expanded as a substitution Also, changed test files relating to the same Signed-off-by: Khush-dev <[email protected]> * Change `output` to `SomeSubstitutionsType` `SomeSubstitutionsType` is a type `Union` already including `Text` Co-authored-by: Michel Hidalgo <[email protected]> Signed-off-by: Khush-dev <[email protected]> Co-authored-by: Michel Hidalgo <[email protected]>
1 parent 6f5f9da commit 8006dfa

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

launch/launch/actions/execute_local.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(
9090
sigkill_timeout: SomeSubstitutionsType = LaunchConfiguration(
9191
'sigkill_timeout', default=5),
9292
emulate_tty: bool = False,
93-
output: Text = 'log',
93+
output: SomeSubstitutionsType = 'log',
9494
output_format: Text = '[{this.process_description.final_name}] {line}',
9595
cached_output: bool = False,
9696
log_cmd: bool = False,
@@ -192,6 +192,7 @@ def __init__(
192192
self.__sigkill_timeout = normalize_to_list_of_substitutions(sigkill_timeout)
193193
self.__emulate_tty = emulate_tty
194194
self.__output = os.environ.get('OVERRIDE_LAUNCH_PROCESS_OUTPUT', output)
195+
self.__output = normalize_to_list_of_substitutions(self.__output)
195196
self.__output_format = output_format
196197

197198
self.__log_cmd = log_cmd
@@ -664,6 +665,7 @@ def execute(self, context: LaunchContext) -> Optional[List[LaunchDescriptionEnti
664665
self.__completed_future = create_future(context.asyncio_loop)
665666
self.__shutdown_future = create_future(context.asyncio_loop)
666667
self.__logger = launch.logging.get_logger(name)
668+
self.__output = perform_substitutions(context, self.__output)
667669
self.__stdout_logger, self.__stderr_logger = \
668670
launch.logging.get_output_loggers(name, self.__output)
669671
context.asyncio_loop.create_task(self.__execute_process(context))

launch/launch/actions/execute_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def parse(
339339
if 'output' not in ignore:
340340
output = entity.get_attr('output', optional=True)
341341
if output is not None:
342-
kwargs['output'] = parser.escape_characters(output)
342+
kwargs['output'] = parser.parse_substitution(output)
343343

344344
if 'respawn' not in ignore:
345345
respawn = entity.get_attr('respawn', data_type=bool, optional=True)

launch_xml/test/launch_xml/test_executable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_executable():
3535
assert executable.cwd[0].perform(None) == '/'
3636
assert executable.name[0].perform(None) == 'my_ls'
3737
assert executable.shell is True
38-
assert executable.output == 'log'
38+
assert executable.output[0].perform(None) == 'log'
3939
key, value = executable.additional_env[0]
4040
key = key[0].perform(None)
4141
value = value[0].perform(None)

launch_yaml/test/launch_yaml/test_executable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_executable():
4747
assert(executable.cwd[0].perform(None) == '/')
4848
assert(executable.name[0].perform(None) == 'my_ls')
4949
assert(executable.shell is True)
50-
assert(executable.output == 'log')
50+
assert(executable.output[0].perform(None) == 'log')
5151
key, value = executable.additional_env[0]
5252
key = key[0].perform(None)
5353
value = value[0].perform(None)

0 commit comments

Comments
 (0)