Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for not optional environment variable substitution #288

Merged
merged 3 commits into from
Jul 26, 2019

Conversation

ivanpauno
Copy link
Member

@ivanpauno ivanpauno commented Jul 25, 2019

Based on comment ros2/ros2_documentation#302 (comment).

This is not exactly what I first commented, but mimics what we where doing in LaunchConfiguration.
I think it makes more sense.

@expose_substitution('var')
class LaunchConfiguration(Substitution):
"""Substitution that can access launch configuration variables."""
def __init__(
self,
variable_name: SomeSubstitutionsType,
*,
default: Optional[Union[Any, Iterable[Any]]] = None

@classmethod
def parse(cls, data: Iterable[SomeSubstitutionsType]):
"""Parse `FindExecutable` substitution."""
if len(data) < 1 or len(data) > 2:
raise TypeError('var substitution expects 1 or 2 arguments')
kwargs = {}
kwargs['variable_name'] = data[0]
if len(data) == 2:
kwargs['default'] = data[1]
return cls, kwargs

This breaks API. If someone was relying on default_value being '', not it will raise a SubstitutionError.
The fix is passing default_value='' explicitly.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I'm ok with this style of providing a non-optional version of this substitution. We cannot, however, back port it (which is ok) and we should add a note to the changelog for Eloquent when that's available.

launch/launch/substitutions/environment_variable.py Outdated Show resolved Hide resolved
launch/launch/substitutions/environment_variable.py Outdated Show resolved Hide resolved
@ivanpauno ivanpauno force-pushed the ivanpauno/non-optional-substitution branch from fbc1fa5 to 444231b Compare July 26, 2019 12:21
@ivanpauno ivanpauno changed the title Add support for non optional environment variable substitution Add support for not optional environment variable substitution Jul 26, 2019
@ivanpauno
Copy link
Member Author

Rebased with master, since there were merge conflicts.

Full CI (only fastrtps):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@ivanpauno
Copy link
Member Author

ivanpauno commented Jul 26, 2019

CI failures are all unrelated. Same three failures on windows' today nightly job.

@wjwwood wjwwood merged commit d4930a9 into master Jul 26, 2019
@delete-merged-branch delete-merged-branch bot deleted the ivanpauno/non-optional-substitution branch July 26, 2019 20:46
piraka9011 pushed a commit to aws-ros-dev/launch that referenced this pull request Aug 16, 2019
)

* Add support for non optional environment variable substitution

Signed-off-by: ivanpauno <[email protected]>

* Address per review comments

Signed-off-by: ivanpauno <[email protected]>

* Correct test in launch_xml

Signed-off-by: ivanpauno <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants