X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FsalomeConsole.py;h=8e0ffcbfa8797e61066965d82a30f001bd20249a;hb=ea6b6e43bd022412bc84bdb6972f689b5a69a95e;hp=a8c4a60a4ff32d6fdc4dd1628328228a4b9af6d5;hpb=bbac39ee34bd6a5e6fd051024209399b97b818b1;p=modules%2Fkernel.git diff --git a/bin/salomeConsole.py b/bin/salomeConsole.py index a8c4a60a4..8e0ffcbfa 100755 --- a/bin/salomeConsole.py +++ b/bin/salomeConsole.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 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 @@ -22,8 +22,18 @@ # 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 + #------------------------------- # Python completion and others if you want # You should have set PYTHONSTARTUP env variable @@ -34,75 +44,71 @@ import user #------------------------------- # Get major CORBA objects #------------------------------- -import CORBA +from omniORB import CORBA import CosNaming -# There are cyclic dependencies between Engines, SALOME and SALOMEDS. -# import first Engines, then SALOME and then SALOMEDS -# Or use reload(Engines) to be safe. -import Engines -import SALOME -import SALOMEDS -import SALOME_ModuleCatalog -reload(Engines) -reload(SALOME) -reload(SALOMEDS) import salome_utils -import LifeCycleCORBA import orbmodule -from runSalome import * -import Utils_Identity -files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(), - "USERS",".omniORB_"+salome_utils.getUserName()+"_*.cfg")) +def getRunningSession(): + omniorbUserPath = os.getenv("OMNIORB_USER_PATH") + files = glob.glob(os.path.join(omniorbUserPath,".omniORB_"+salome_utils.getUserName()+"_*[!last].cfg")) -filename="" -if len(files)==1: - filename=files[0] -else: - print "You have %d sessions running" % len(files) - for f in files: - print "Session:",f - rep= raw_input("Do you want to connect to this session [y|n]") - if rep == "y": + filename="" + if len(files)==1: + filename=files[0] + else: + print "You have %d sessions running" % len(files) + for f in files: + print "Session:",f + rep= raw_input("Do you want to connect to this session [y|n]") + if rep == "y": filename=f break - -if filename != "": - os.environ['OMNIORB_CONFIG']=filename -else: - rep= raw_input("Do you want to try a local session on port 2810 ? [y|n]") - if rep == "y": - # Try a local session running on port 2810 - sys.argv=sys.argv+['-ORBInitRef','NameService=corbaname::localhost:2810'] - else: - sys.exit(1) - -print sys.argv -#direct adress from clt.orb.object_to_string(clt.rootContext) -#sys.argv=sys.argv+['-ORBInitRef','NameService=IOR:010000000100000000000000010000000000000023000000010100000a0000006c6f63616c686f737400fa0a0b0000004e616d6553657276696365'] + if filename != "": + os.environ['OMNIORB_CONFIG']=filename + else: + rep= raw_input("Do you want to try a local session on port 2810 ? [y|n]") + if rep == "y": + # Try a local session running on port 2810 + sys.argv=sys.argv+['-ORBInitRef','NameService=corbaname::localhost:2810'] + else: + sys.exit(1) +# 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 +# -clt=client() -print "Naming Service address: ",clt.orb.object_to_string(clt.rootContext) +def startClient(): + try: + clt=client() + except Exception: + sys.exit(1) + # + print "Naming Service address: ",clt.orb.object_to_string(clt.rootContext) -clt.showNS() + clt.showNS() + + 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 + salome.salome_init() + from salome import lcc +# -session=clt.waitNS("/Kernel/Session") -catalog=clt.waitNS("/Kernel/ModulCatalog") -studyMgr=clt.waitNS("/myStudyManager") -import salome -salome.salome_init() -from salome import lcc +getRunningSession() +startClient()