Skip to content

Commit

Permalink
Simplify prefix application
Browse files Browse the repository at this point in the history
Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>
  • Loading branch information
camm73 and hidmic committed Aug 23, 2021
1 parent ff6bf18 commit a23f33c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions launch/launch/actions/execute_process.py
Expand Up @@ -687,15 +687,12 @@ def __expand_substitutions(self, context):
else perform_substitutions(context, self.__name)

# Perform filtering for prefix application
filter_str = perform_substitutions(context, self.__prefix_filter)
regex_filter = None
if len(filter_str):
regex_filter = re.compile(filter_str)
if regex_filter is not None and regex_filter.match(os.path.basename(cmd[0])):
cmd = shlex.split(perform_substitutions(context, self.__prefix)) + cmd

# Apply to all if no filter is provided or filter is overridden
if regex_filter is None or self.__override_filter:
should_apply_prefix = True # by default
if self.__prefix_filter is not None: # no prefix given on construction
prefix_filter = perform_substitutions(context, self.__prefix_filter)
# Apply if filter regex matches (empty regex matches all strings)
should_apply_prefix = re.match(prefix_filter, os.path.basename(cmd[0]))
if should_apply_prefix:
cmd = shlex.split(perform_substitutions(context, self.__prefix)) + cmd

with _global_process_counter_lock:
Expand Down

0 comments on commit a23f33c

Please sign in to comment.