2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # SALOME Utils : general SALOME's definitions and tools
24 # File : Utils_Identity.py
25 # Author : Estelle Deville, CEA
33 if not sys.platform == "win32":
39 def getShortHostName():
41 gives Hostname without domain extension.
42 SALOME naming service needs short Hostnames (without domain extension).
43 HOSTNAME is not allways defined in environment,
44 socket.gethostname() gives short or complete Hostname, depending on
47 return string.split(socket.gethostname(),'.')[0]
50 def __init__(self,name):
52 self._pid = os.getpid()
53 self._machine = socket.gethostname()
54 self._adip = socket.gethostbyname(self._machine) # IP adress
55 if sys.platform == "win32":
56 self._uid = os.getpid()
57 self._pwname = os.environ["USER"]
59 self._uid = os.getuid()
60 list = pwd.getpwuid(self._uid)
61 self._pwname = list[0] # user name
63 self._tc_start = time.time()
64 self._cstart = time.ctime(self._tc_start)
65 self._cdir = os.getcwd()
69 Gives short application path (the complete path is $HOME/$APPLI)
71 return os.environ.get("APPLI",".salome_"+versnb)
74 file = open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r")
76 versnb = string.strip(string.split(s, ":")[1])
77 dirname=".salome_"+versnb
84 Gives salome version number