[openrtm-commit:00290] r432 - branches/RELENG_1_1/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 8月 2日 (火) 21:11:51 JST
Author: kurihara
Date: 2011-08-02 21:11:50 +0900 (Tue, 02 Aug 2011)
New Revision: 432
Modified:
branches/RELENG_1_1/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py
Log:
Changed the delimiter of the pass from "/" to os.sep.
Modified: branches/RELENG_1_1/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py
===================================================================
--- branches/RELENG_1_1/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py 2011-08-02 12:04:56 UTC (rev 431)
+++ branches/RELENG_1_1/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py 2011-08-02 12:11:50 UTC (rev 432)
@@ -258,6 +258,7 @@
import_name = os.path.split(file_name)[-1]
pathChanged=False
+ file_path = None
if OpenRTM_aist.isAbsolutePath(file_name):
if not self._absoluteAllowed:
raise ModuleManager.NotAllowedOperation, "Absolute path is not allowed"
@@ -267,14 +268,20 @@
sys.path.append(splitted_name[0])
pathChanged = True
import_name = splitted_name[-1]
+ file_path = file_name
else:
- if not self.findFile(file_name, self._loadPath):
+ file_path = self.findFile(file_name, self._loadPath)
+ if not file_path:
raise ModuleManager.InvalidArguments, "Invalid file name."
- if not self.fileExist(file_name):
- raise ModuleManager.FileNotFound, file_path
+ if not self.fileExist(file_path):
+ raise ModuleManager.FileNotFound, file_name
+ if not pathChanged:
+ splitted_name = os.path.split(file_path)
+ sys.path.append(splitted_name[0])
+
ext_pos = import_name.find(".py")
if ext_pos > 0:
import_name = import_name[:ext_pos]
@@ -284,14 +291,14 @@
sys.path = save_path
dll = self.DLLEntity(mo,OpenRTM_aist.Properties())
- dll.properties.setProperty("file_path",file_name)
+ dll.properties.setProperty("file_path",file_path)
self._modules.registerObject(dll)
if init_func is None:
return file_name
- self.symbol(file_name,init_func)(self._mgr)
+ self.symbol(file_path,init_func)(self._mgr)
return file_name
@@ -508,7 +515,7 @@
if path == "":
continue
- flist = glob.glob(path+"/"+'*.py')
+ flist = glob.glob(path + os.sep + '*.py')
for file in flist:
if file.find("__init__.py") == -1:
modules_.append(file)
@@ -607,11 +614,11 @@
file_name = fname
for path in load_path:
if fname.find(".py") == -1:
- f = str(path)+"/"+str(file_name)+".py"
+ f = str(path) + os.sep + str(file_name)+".py"
else:
- f = str(path)+"/"+str(file_name)
+ f = str(path)+ os.sep + str(file_name)
if self.fileExist(f):
- return fname
+ return f
return ""
@@ -633,15 +640,14 @@
fname = filename
if fname.find(".py") == -1:
fname = str(filename)+".py"
- try:
- infile = open(fname)
- except:
- return False
- infile.close()
- return True
+ if os.path.isfile(fname):
+ return True
+ return False
+
+
##
# @if jp
# @brief 初期化関数シンボルを生成する
openrtm-commit メーリングリストの案内