[openrtm-commit:03105] r923 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 1月 23日 (火) 11:23:31 JST
Author: miyamoto
Date: 2018-01-23 11:23:30 +0900 (Tue, 23 Jan 2018)
New Revision: 923
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerConfig.py
trunk/OpenRTM-aist-Python/OpenRTM_aist/StringUtil.py
Log:
[compat, bugfix, ->RELENG_1_2] refs #4424
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerConfig.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerConfig.py 2018-01-23 02:19:21 UTC (rev 922)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ManagerConfig.py 2018-01-23 02:23:30 UTC (rev 923)
@@ -81,7 +81,6 @@
class ManagerConfig :
"""
"""
-
##
# @if jp
# @brief Manager ¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¤Î¥Ç¥Õ¥©¥ë¥È¡¦¥Õ¥¡¥¤¥ë¡¦¥Ñ¥¹
@@ -88,14 +87,21 @@
# @else
# @brief The default configuration file path for manager
# @endif
- config_file_path = ["./rtc.conf",
- "/etc/rtc.conf",
- "/etc/rtc/rtc.conf",
- "/usr/local/etc/rtc.conf",
- "/usr/local/etc/rtc/rtc.conf",
- None]
+ if sys.platform == 'win32':
+ config_file_path = ["./rtc.conf",
+ "\%RTM_ROOT\%/bin/\%RTM_VC_VERSION\%/rtc.conf",
+ "C:/Python"+str(sys.version_info[0])+str(sys.version_info[1])+"/rtc.conf",
+ None]
+ else:
+ config_file_path = ["./rtc.conf",
+ "/etc/rtc.conf",
+ "/etc/rtc/rtc.conf",
+ "/usr/local/etc/rtc.conf",
+ "/usr/local/etc/rtc/rtc.conf",
+ None]
+
##
# @if jp
# @brief ¥Ç¥Õ¥©¥ë¥È¡¦¥³¥ó¥Õ¥£¥®¥å¥ì¡¼¥·¥ç¥ó¤Î¥Õ¥¡¥¤¥ë¡¦¥Ñ¥¹¤ò¼±Ê̤¹¤ë
@@ -339,6 +345,7 @@
i = 0
while (self.config_file_path[i]):
+ self.config_file_path[i] = OpenRTM_aist.replaceEnv(self.config_file_path[i])
if self.fileExist(self.config_file_path[i]):
self._configFile = self.config_file_path[i]
return True
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/StringUtil.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/StringUtil.py 2018-01-23 02:19:21 UTC (rev 922)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/StringUtil.py 2018-01-23 02:23:30 UTC (rev 923)
@@ -14,6 +14,7 @@
# Advanced Industrial Science and Technology (AIST), Japan
# All rights reserved.
+import os
import sys
if sys.version_info[0] == 3:
long = int
@@ -651,3 +652,71 @@
# @endif
def toArgv(args):
return args
+
+
+
+
+##
+# @if jp
+# @brief URL¥Ñ¥é¥á¡¼¥¿¤òmapstring¤Ëʬ²ò¤·¤ÆÊÖ¤¹
+#
+# URL¥Ñ¥é¥á¡¼¥¿É½¸½ something?key0=value0&key1=value1.... ¤Î¤¦¤Á
+# '?' °Ê¹ß¤ÎÉôʬ¤òʬ²ò¤·¤Æ¡¢std::map<std::string, std::string> ·Á¼°
+# ¤ËÊÑ´¹¤¹¤ë¡£Í¿¤¨¤é¤ì¤¿Ê¸»úÎó¤òº¸¤«¤é¥µ¡¼¥Á¤·¡¢'?' ¤è¤ê±¦Â¦¤ÎÉôʬ¤Ë
+# ¤Ä¤¤¤Æ²òÀϤò¹Ô¤¦¡£'&'¤Çʬ³ä¤·¡¢º¸¤«¤é '=' ¤ò¸¡º÷¤·¡¢ºÇ½é¤Î '=' ¤Î
+# ±¦ÊդȺ¸ÊÕ¤ò¤½¤ì¤¾¤ì¡¢key ¤È value ¤È¤·¤Æ map ¤Ë³ÊǼ¤¹¤ë¡£
+#
+# @param str ʬ²òÂоÝʸ»úÎó
+# @return mapstring ·¿¤Î key/value¥Ç¡¼¥¿
+#
+#
+# @else
+# @brief Investigate whether the given string is URL or not
+#
+# URL parameter description such as
+# something?key0=value0&key1=value1.... is analyzed. Right hand
+# side string of '?' character is decomposed and it is converted
+# into std::map<std::string, std::string> type.The following string
+# are devided by '&' and then '=' character is
+# searched. Right-hand-side value and left-hand-side value of '='
+# are stored as key and value in the map.
+#
+# @param str The target string for decomposed
+#
+# @return decomposed key-values in map
+#
+# @endif
+def urlparam2map(_str):
+ qpos = _str.find("?")
+ if qpos == -1:
+ qpos = 0
+ else:
+ qpos+=1
+ tmp = _str[qpos:].split("&")
+ retmap = {}
+ for v in tmp:
+ pos = v.find("=")
+ if pos != -1:
+ retmap[v[0:pos]] = v[pos+1:]
+ else:
+ retmap[v] = ""
+ return retmap
+
+
+def replaceEnv(_str):
+ tmp = _str.split("\%")
+ if len(tmp) < 3:
+ return _str
+ ret = []
+ for i in range(len(tmp)):
+ if i%2 == 1:
+ if tmp[i] in os.environ:
+ ret.append(os.environ[tmp[i]])
+ else:
+ ret.append(tmp[i])
+ ret_str = ""
+ for s in ret:
+ ret_str = ret_str + s
+ return ret_str
+
+
\ No newline at end of file
More information about the openrtm-commit
mailing list