-
Notifications
You must be signed in to change notification settings - Fork 914
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
[roslaunch] Add yaml type for <param> tag #1045
Merged
dirk-thomas
merged 11 commits into
ros:lunar-devel
from
wkentaro:roslaunch_param_command_type_yaml
Jul 7, 2017
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b44af6c
Add yaml type for <param> tag
wkentaro 242cfcd
Support type for command output of <param> tag
wkentaro 7c80460
Add test for yaml type
wkentaro 0112b87
Add test for identifying commandline output as types
wkentaro ea65411
Support yaml type with textfile for <param>
wkentaro b746f71
Reserve current behavior with handling strip cleanly
wkentaro 5b8718c
Revert <test_depend>rospy</test_depend>: no need
wkentaro 2d8ae09
Revert no need strip()
wkentaro 6e3e0b0
Remove the lazy import for yaml
wkentaro 412d56e
Raise ValueError for yaml parse error
wkentaro c907f36
Strip for boolean rosparam
wkentaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,13 @@ | |
import os | ||
from copy import deepcopy | ||
|
||
import yaml | ||
|
||
from roslaunch.core import Param, RosbinExecutable, RLException, PHASE_SETUP | ||
|
||
from rosgraph.names import make_global_ns, ns_join, PRIV_NAME, load_mappings, is_legal_name, canonicalize_name | ||
|
||
#lazy-import global for yaml and rosparam | ||
yaml = None | ||
rosparam = None | ||
|
||
class LoadException(RLException): | ||
|
@@ -94,6 +95,8 @@ def convert_value(value, type_): | |
elif value == 'false' or value == '0': | ||
return False | ||
raise ValueError("%s is not a '%s' type"%(value, type_)) | ||
elif type_ == 'yaml': | ||
return yaml.load(value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should any yaml specific exceptions be catched here and a |
||
else: | ||
raise ValueError("Unknown type '%s'"%type_) | ||
|
||
|
@@ -395,10 +398,6 @@ def load_rosparam(self, context, ros_config, cmd, param, file_, text, verbose=Tr | |
text = f.read() | ||
|
||
# parse YAML text | ||
# - lazy import | ||
global yaml | ||
if yaml is None: | ||
import yaml | ||
# - lazy import: we have to import rosparam in oder to to configure the YAML constructors | ||
global rosparam | ||
if rosparam is None: | ||
|
@@ -468,7 +467,7 @@ def param_value(self, verbose, name, ptype, value, textfile, binfile, command): | |
return convert_value(value.strip(), ptype) | ||
elif textfile is not None: | ||
with open(textfile, 'r') as f: | ||
return f.read() | ||
return convert_value(f.read(), ptype) | ||
elif binfile is not None: | ||
try: | ||
from xmlrpc.client import Binary | ||
|
@@ -498,7 +497,7 @@ def param_value(self, verbose, name, ptype, value, textfile, binfile, command): | |
raise | ||
if c_value is None: | ||
raise ValueError("parameter: unable to get output of command [%s]"%command) | ||
return c_value | ||
return convert_value(c_value, ptype) | ||
else: #_param_tag prevalidates, so this should not be reachable | ||
raise ValueError("unable to determine parameter value") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is that represented on the parameter server? Does this store a complex type (e.g. a nested dictionary) under a single
name
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is set like this: