]> SALOME platform Git repositories - modules/kernel.git/blob - bin/salomeConsole.py
Salome HOME
Issue 0020794: A strange cast (const char*) --> bool in SALOME_ModuleCatalog_Handler.cxx
[modules/kernel.git] / bin / salomeConsole.py
1 #!/usr/bin/env python
2 #  -*- coding: iso-8859-1 -*-
3 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
4 #
5 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 #
8 #  This library is free software; you can redistribute it and/or
9 #  modify it under the terms of the GNU Lesser General Public
10 #  License as published by the Free Software Foundation; either
11 #  version 2.1 of the License.
12 #
13 #  This library is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 #  Lesser General Public License for more details.
17 #
18 #  You should have received a copy of the GNU Lesser General Public
19 #  License along with this library; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 #
22 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #
24 import os
25 import sys
26 #-------------------------------
27 # Python completion and others if you want
28 # You should have set PYTHONSTARTUP env variable
29 # or import user should try to import $HOME/.pythonrc.py
30 #-------------------------------
31 import user
32
33 #-------------------------------
34 # Get major CORBA objects
35 #-------------------------------
36 import CORBA
37 import CosNaming
38 # There are cyclic dependencies between Engines, SALOME and SALOMEDS.
39 # import first Engines, then SALOME and then SALOMEDS
40 # Or use reload(Engines) to be safe.
41 import Engines
42 import SALOME
43 import SALOMEDS
44 import SALOME_ModuleCatalog
45 reload(Engines)
46 reload(SALOME)
47 reload(SALOMEDS)
48 import salome_utils
49
50 import LifeCycleCORBA
51 import orbmodule
52 from runSalome import *
53
54 import Utils_Identity
55 files = glob.glob(os.path.join(os.environ["HOME"],Utils_Identity.getapplipath(),
56                                "USERS",".omniORB_"+salome_utils.getUserName()+"_*.cfg"))
57
58 filename=""
59 if len(files)==1:
60   filename=files[0]
61 else:
62   print "You have %d sessions running" % len(files)
63   for f in files:
64      print "Session:",f
65      rep= raw_input("Do you want to connect to this session [y|n]")
66      if rep == "y":
67         filename=f
68         break
69      
70 if filename != "":
71   os.environ['OMNIORB_CONFIG']=filename
72 else:
73   rep= raw_input("Do you want to try a local session on port 2810 ? [y|n]")
74   if rep == "y":
75      # Try a local session running on port 2810
76      sys.argv=sys.argv+['-ORBInitRef','NameService=corbaname::localhost:2810']
77   else:
78      sys.exit(1)
79
80 print sys.argv
81
82 #direct adress from clt.orb.object_to_string(clt.rootContext)
83 #sys.argv=sys.argv+['-ORBInitRef','NameService=IOR:010000000100000000000000010000000000000023000000010100000a0000006c6f63616c686f737400fa0a0b0000004e616d6553657276696365']
84
85 class client(orbmodule.client):
86    def initNS(self,args):
87       # Obtain a reference to the root naming context
88       obj         = self.orb.resolve_initial_references("NameService")
89       try:
90           self.rootContext = obj._narrow(CosNaming.NamingContext)
91           return
92       except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
93           print "It's not a valid naming service"
94           self.rootContext = None
95           raise
96
97 clt=client()
98 print "Naming Service address: ",clt.orb.object_to_string(clt.rootContext)
99
100 clt.showNS()
101
102 session=clt.waitNS("/Kernel/Session")
103 catalog=clt.waitNS("/Kernel/ModulCatalog")
104 studyMgr=clt.waitNS("/myStudyManager")
105 import salome
106 salome.salome_init()
107 from salome import lcc