Salome HOME
Port manager's lock file should be created with proper permissions; we must use umask...
[modules/kernel.git] / bin / salomeConsole.py
index 46036d3e712595e9365a79aceff6d97194cdd59e..65248d45c2d4a2755bb505d249c357c8fa12b9e9 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2015  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
@@ -8,7 +8,7 @@
 # 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.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+###############################################
+############### IMPORTANT NOTE ################
+###############################################
+# The salomeConsole.py script is obsolete.    #
+# Please consider the new salome launcher.    #
+###############################################
+
+
 import os
 import sys
 import glob
@@ -36,7 +44,7 @@ import user
 #-------------------------------
 # Get major CORBA objects
 #-------------------------------
-import CORBA
+from omniORB import CORBA
 import CosNaming
 import salome_utils
 
@@ -44,7 +52,7 @@ import orbmodule
 
 def getRunningSession():
   omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
-  files = glob.glob(os.path.join(omniorbUserPath,".omniORB_"+salome_utils.getUserName()+"_*.cfg"))
+  files = glob.glob(os.path.join(omniorbUserPath,".omniORB_"+salome_utils.getUserName()+"_*[!last].cfg"))
 
   filename=""
   if len(files)==1:
@@ -70,16 +78,16 @@ def getRunningSession():
 #
 
 class client(orbmodule.client):
-   def initNS(self,args):
-      # Obtain a reference to the root naming context
-      obj = self.orb.resolve_initial_references("NameService")
-      try:
-          self.rootContext = obj._narrow(CosNaming.NamingContext)
-          return
-      except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
-          print "It's not a valid naming service"
-          self.rootContext = None
-          raise
+  def initNS(self,args):
+    # Obtain a reference to the root naming context
+    obj = self.orb.resolve_initial_references("NameService")
+    try:
+      self.rootContext = obj._narrow(CosNaming.NamingContext)
+      return
+    except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
+      print "It's not a valid naming service"
+      self.rootContext = None
+      raise
 #
 
 def startClient():
@@ -92,7 +100,9 @@ def startClient():
 
   clt.showNS()
 
-  session=clt.waitNS("/Kernel/Session")
+  session_server = clt.Resolve('/Kernel/Session')
+  if session_server:
+    session=clt.waitNS("/Kernel/Session")
   catalog=clt.waitNS("/Kernel/ModulCatalog")
   studyMgr=clt.waitNS("/myStudyManager")
   import salome