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

create_component関数の引数の不具合修正 #305

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions OpenRTM_aist/ManagerServant.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@ def create_component(self, module_name):

self._rtcout.RTC_TRACE("create_component(%s)", module_name)

if module_name.find("?") == 0:
self._rtcout.RTC_ERROR("Module name is empty.")
return RTC.RTObject._nil
elif "?" not in module_name and "=" in module_name:
self._rtcout.RTC_ERROR("Incorrect module name.")
return RTC.RTObject._nil

rtc, module_name, manager_address = self.createComponentByAddress(
module_name)

Expand Down Expand Up @@ -530,8 +537,14 @@ def create_component(self, module_name):
OpenRTM_aist.Logger.print_exception())
self._slaves.remove(slave)
del guard

if not manager_name:
module_name = module_name + "&manager_name=manager_%p"
props = OpenRTM_aist.urlparam2map(module_name)
if not props:
module_name += "?"
else:
module_name += "&"
module_name = module_name + "manager_name=manager_%p"

rtc, _, _ = self.createComponentByManagerName(module_name)
return rtc
Expand Down Expand Up @@ -1311,47 +1324,34 @@ def findManagerByName(self, manager_name):
# std::string getParameterByModulename(string param_name, string
# &module_name)
def getParameterByModulename(self, param_name, module_name):
arg = module_name
pos0 = arg.find("&" + param_name + "=")
pos1 = arg.find("?" + param_name + "=")
id_and_conf = [s.strip() for s in module_name.split("?")]

if pos0 == -1 and pos1 == -1:
if len(id_and_conf) != 2:
return "", module_name

id = id_and_conf[0]

props = OpenRTM_aist.urlparam2map(module_name)

if param_name in props.keys():
paramstr = props.pop(param_name)
self._rtcout.RTC_VERBOSE("%s arg: %s", (param_name, paramstr))
module_name = id
if len(props) > 0:
module_name += "?"
i = 0
for key, value in props.items():
if i > 0:
module_name += "&"
i += 1
module_name += key + "=" + value
return paramstr, module_name

pos = 0
if pos0 == -1:
pos = pos1
else:
pos = pos0

paramstr = ""
endpos = arg.find('&', pos + 1)
if endpos == -1:
endpos = arg.find('?', pos + 1)
if endpos == -1:
paramstr = arg[(pos + 1):]
else:
paramstr = arg[(pos + 1): endpos]
else:
paramstr = arg[(pos + 1): endpos]
self._rtcout.RTC_VERBOSE("%s arg: %s", (param_name, paramstr))

eqpos = paramstr.find("=")
# if eqpos == -1:
# self._rtcout.RTC_WARN("Invalid argument: %s", module_name)
# return ""

paramstr = paramstr[eqpos + 1:]
self._rtcout.RTC_DEBUG("%s is %s", (param_name, paramstr))

if endpos == -1:
arg = arg[:pos]
else:
arg = arg[:pos] + arg[endpos:]

module_name = arg
return "", module_name


return paramstr, module_name

##
# @if jp
Expand Down
8 changes: 5 additions & 3 deletions OpenRTM_aist/StringUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,13 @@ def urlparam2map(_str):
tmp = _str[qpos:].split("&")
retmap = {}
for v in tmp:
if not v.strip():
continue
pos = v.find("=")
if pos != -1:
retmap[v[0:pos]] = v[pos + 1:]
else:
retmap[v] = ""
key = v[0:pos]
if key.strip():
retmap[key] = v[pos + 1:]
return retmap

##
Expand Down
Loading