Back to index

salome-kernel  6.5.0
NSparam.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 #  -*- coding: iso-8859-1 -*-
00003 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00004 #
00005 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00006 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00007 #
00008 # This library is free software; you can redistribute it and/or
00009 # modify it under the terms of the GNU Lesser General Public
00010 # License as published by the Free Software Foundation; either
00011 # version 2.1 of the License.
00012 #
00013 # This library is distributed in the hope that it will be useful,
00014 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 # Lesser General Public License for more details.
00017 #
00018 # You should have received a copy of the GNU Lesser General Public
00019 # License along with this library; if not, write to the Free Software
00020 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00021 #
00022 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00023 #
00024 
00025 import sys,os
00026 
00027 def getNSparams(info=""):
00028     """
00029     check environment for omniORB configuration file.
00030     parse the file to find the line defining naming service  host and port,
00031     set environment variables NSPORT and NSHOST,
00032     get host and port,
00033     if   info==host print host
00034     elif info==port print host
00035     else    print 2 strings on stdout on one line: host port
00036     """
00037     from salome_utils import getORBcfgInfo
00038     my_version, my_host, my_port = getORBcfgInfo()
00039     if info=='host':
00040         # keep print, stdout used in shell
00041         print my_host
00042         os.environ['NSHOST']=my_host
00043         return my_host
00044         pass
00045     elif info=='port':
00046         # keep print, stdout used in shell
00047         print my_port
00048         os.environ['NSPORT']=my_port
00049         return my_port
00050         pass
00051     else:
00052         # keep print, stdout used in shell
00053         print  my_host, my_port
00054         return my_host, my_port
00055     pass
00056 
00057 # ------------------------------------------------------------------------
00058 
00059 if __name__ == "__main__":
00060     if len(sys.argv) >1:        
00061         if sys.argv[1]=='host':
00062             getNSparams('host')
00063             pass
00064         elif sys.argv[1]=='port':
00065             getNSparams('port')
00066             pass
00067         else:
00068             getNSparams()
00069             pass
00070         pass
00071     else:
00072         getNSparams()
00073         pass
00074     pass