Skip to content

Commit 7d80ea0

Browse files
author
Roger Strain
committed
Refactor arguments to apply to executable
Distro A; OPSEC #4584 Signed-off-by: Roger Strain <[email protected]>
1 parent 7c247cf commit 7d80ea0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

launch/launch/descriptions/executable.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
cwd: Optional[SomeSubstitutionsType] = None,
5555
env: Optional[Dict[SomeSubstitutionsType, SomeSubstitutionsType]] = None,
5656
additional_env: Optional[Dict[SomeSubstitutionsType, SomeSubstitutionsType]] = None,
57+
arguments: Optional[Iterable[SomeSubstitutionsType]] = None,
5758
) -> None:
5859
"""
5960
Initialize an Executable description.
@@ -72,8 +73,10 @@ def __init__(
7273
:param additional_env: Dictionary of environment variables to be added. If env was
7374
None, they are added to the current environment. If not, env is updated with
7475
additional_env.
76+
:param: arguments list of extra arguments for the executable
7577
"""
7678
self.__cmd = [normalize_to_list_of_substitutions(x) for x in cmd]
79+
self.__cmd += [] if arguments is None else [normalize_to_list_of_substitutions(x) for x in arguments]
7780
self.__prefix = normalize_to_list_of_substitutions(
7881
LaunchConfiguration('launch-prefix', default='') if prefix is None else prefix
7982
)
@@ -93,6 +96,7 @@ def __init__(
9396
self.__additional_env.append((
9497
normalize_to_list_of_substitutions(key),
9598
normalize_to_list_of_substitutions(value)))
99+
self.__arguments = arguments
96100
self.__final_cmd = None
97101
self.__final_cwd = None
98102
self.__final_env = None
@@ -128,6 +132,11 @@ def additional_env(self):
128132
"""Getter for additional_env."""
129133
return self.__additional_env
130134

135+
@property
136+
def arguments(self):
137+
"""Getter for arguments."""
138+
return self.__arguments
139+
131140
@property
132141
def final_name(self):
133142
"""Getter for final_name."""
@@ -148,7 +157,7 @@ def final_env(self):
148157
"""Getter for final_env."""
149158
return self.__final_env
150159

151-
def prepare(self, action: Action, context: LaunchContext):
160+
def prepare(self, context: LaunchContext, action: Action):
152161
"""
153162
Prepare an executable description for execution in a given environment.
154163

launch/test/launch/test_executable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_substituted_properties():
6868
os.environ['EXECUTABLE_ENVVAL'] = 'value'
6969
name = EnvironmentVariable('EXECUTABLE_NAME')
7070
cwd = EnvironmentVariable('EXECUTABLE_CWD')
71-
env = {EnvironmentVariable('EXECUTABLE_EV'): EnvironmentVariable('EXECUTABLE_ENVVAL')}
71+
env = {EnvironmentVariable('EXECUTABLE_ENVVAR'): EnvironmentVariable('EXECUTABLE_ENVVAL')}
7272
exe = Executable(cmd=['test'], name=name, cwd=cwd, env=env)
7373
exe.prepare(None, LaunchContext())
7474
assert exe.final_name.startswith('name')

0 commit comments

Comments
 (0)