[openrtm-commit:02599] r822 - trunk/OpenRTM-aist-Python/OpenRTM_aist

openrtm @ openrtm.org openrtm @ openrtm.org
2017年 4月 28日 (金) 13:36:34 JST


Author: miyamoto
Date: 2017-04-28 13:36:34 +0900 (Fri, 28 Apr 2017)
New Revision: 822

Modified:
   trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
   trunk/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py
Log:
refs #4030

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py	2017-04-24 06:57:24 UTC (rev 821)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/Manager.py	2017-04-28 04:36:34 UTC (rev 822)
@@ -534,6 +534,11 @@
   # @param self
   # @param fname   モジュールファイル名
   # @param initfunc 初期化関数名
+  # @return エラーコード
+  #         RTC::RTC_OK 正常終了
+  #         RTC::RTC_ERROR ロード失敗・不明なエラー
+  #         RTC::PRECONDITION_NOT_MET 設定により許可されない操作
+  #         RTC::BAD_PARAMETER 不正なパラメータ
   # 
   # @else
   #
@@ -544,6 +549,11 @@
   #
   # @param fname    The module file name
   # @param initfunc The initialize function name
+  # @return Return code
+  #         RTC::RTC_OK Normal return
+  #         RTC::RTC_ERROR Load failed, or unknown error
+  #         RTC::PRECONDITION_NOT_MET Not allowed operation by conf
+  #         RTC::BAD_PARAMETER Invalid parameter
   #
   # @endif
   def load(self, fname, initfunc):
@@ -552,6 +562,7 @@
     self._listeners.module_.preLoad(fname, initfunc)
     try:
       fname_ = fname.split(os.sep)
+      
       if len(fname_) > 1:
         fname_ = fname_[-1]
       else:
@@ -563,10 +574,27 @@
       path = self._module.load(fname, initfunc)
       self._rtcout.RTC_DEBUG("module path: %s", path)
       self._listeners.module_.postLoad(path, initfunc)
+    except OpenRTM_aist.ModuleManager.NotAllowedOperation as e:
+      self._rtcout.RTC_ERROR("Operation not allowed: %s",(e.reason))
+      return RTC.PRECONDITION_NOT_MET
+    except OpenRTM_aist.ModuleManager.NotFound:
+      self._rtcout.RTC_ERROR("Not found: %s",(fname))
+      return RTC.RTC_ERROR
+    except OpenRTM_aist.ModuleManager.FileNotFound:
+      self._rtcout.RTC_ERROR("Not found: %s",(fname))
+      return RTC.RTC_ERROR
+    except OpenRTM_aist.ModuleManager.InvalidArguments as e:
+      self._rtcout.RTC_ERROR("Invalid argument: %s",(e.reason))
+      return RTC.BAD_PARAMETER
+    #except OpenRTM_aist.ModuleManager.Error as e:
+    #  self._rtcout.RTC_ERROR("Error: %s",(e.reason))
+    #  return RTC.RTC_ERROR
     except:
-      self.__try_direct_load(fname)
+      self._rtcout.RTC_ERROR("Unknown error.")
+      return RTC.RTC_ERROR
+      #self.__try_direct_load(fname)
 
-    return
+    return RTC.RTC_OK
 
 
   ##
@@ -3388,7 +3416,8 @@
 
 
     def __del__(self):
-      self._th.join()
+      pass
+      #self._th.join()
       #self._th = None
       #return
 

Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py	2017-04-24 06:57:24 UTC (rev 821)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/ModuleManager.py	2017-04-28 04:36:34 UTC (rev 822)
@@ -274,7 +274,7 @@
     else:
       file_path = self.findFile(file_name, self._loadPath)
       if not file_path:
-        raise ModuleManager.InvalidArguments, "Invalid file name."
+        raise ModuleManager.FileNotFound, file_name
   
     if not self.fileExist(file_path):
       raise ModuleManager.FileNotFound, file_name



openrtm-commit メーリングリストの案内