Salome HOME
CCAR: import_hook.py was too strict in ensure_list (ImportError raised)
[modules/kernel.git] / src / KERNEL_PY / batchmode_salome.py
index abd099f1f3d40c8b5f5872efc991deea234ba374..9dea7faaf0524fef023e842cb2b5a3a381df310c 100755 (executable)
@@ -1,12 +1,30 @@
-#  Copyright (C) 2003  CEA/DEN, EDF R&D
+#  -*- coding: iso-8859-1 -*-
+#  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 #
+#  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
 #
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
+#
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 #  File   : batchmode_salome.py
 #  Module : SALOME
-
-import salome_shared_modules
-
+#import salome_shared_modules
+#
 from omniORB import CORBA
 from LifeCycleCORBA import *
 import SALOME
@@ -217,11 +235,17 @@ def FindFileInDataDir(filename):
 orb = None
 
 step = 0
-while step < 100 and orb is None:
+sleeping_time = 0.01
+sleeping_time_max = 1.0
+while 1:
     orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+    if orb is not None: break
     step = step + 1
-    time.sleep(4)
-
+    if step > 100: break
+    time.sleep(sleeping_time)
+    sleeping_time = max(sleeping_time_max, 2*sleeping_time)
+    pass
+    
 if orb is None:
     print "Warning: ORB has not been initialized !!!"
 
@@ -229,10 +253,16 @@ if orb is None:
 lcc = LifeCycleCORBA(orb)
 
 step = 0
-while step < 100 and lcc is None:
+sleeping_time = 0.01
+sleeping_time_max = 1.0
+while 1:
     lcc = LifeCycleCORBA(orb)
+    if lcc is not None: break
     step = step + 1
-    time.sleep(4)
+    if step > 100: break
+    time.sleep(sleeping_time)
+    sleeping_time = max(sleeping_time_max, 2*sleeping_time)
+    pass
     
 if lcc is None:
     print "Warning: LifeCycleCORBA object has not been initialized !!!"
@@ -244,10 +274,16 @@ naming_service = SALOME_NamingServicePy_i(orb)
 obj = None
 
 step = 0
-while step < 100 and obj == None:
+sleeping_time = 0.01
+sleeping_time_max = 1.0
+while 1:
     obj = naming_service.Resolve('myStudyManager')
+    if obj is not None:break
     step = step + 1
-    time.sleep(4)
+    if step > 100: break
+    time.sleep(sleeping_time)
+    sleeping_time = max(sleeping_time_max, 2*sleeping_time)
+    pass
      
 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
 
@@ -266,5 +302,5 @@ else:
 myStudyName = myStudy._get_Name()
 
 myStudyId = myStudy._get_StudyId()
-print myStudyId
+#print myStudyId