1 #! /usr/bin/env python3
2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 # SALOME Utils : general SALOME's definitions and tools
26 # File : Utils_Identity.py
27 # Author : Estelle Deville, CEA
30 ## @package Utils_Identity
31 # \brief Module to get information about user and version
37 if not sys.platform == "win32":
43 def getShortHostName():
45 gives Hostname without domain extension.
47 SALOME naming service needs short Hostnames (without domain extension).
48 HOSTNAME is not always defined in environment,
49 socket.gethostname() gives short or complete Hostname, depending on
52 hostname = socket.gethostname()
53 return hostname.split('.')[0]
56 def __init__(self,name):
58 self._pid = os.getpid()
59 self._machine = socket.gethostname()
60 self._adip = socket.gethostbyname(self._machine) # IP address
61 if sys.platform == "win32":
62 self._uid = os.getpid()
63 self._pwname = os.environ["USERNAME"]
65 self._uid = os.getuid()
66 list = pwd.getpwuid(self._uid)
67 self._pwname = list[0] # user name
69 self._tc_start = time.time()
70 self._cstart = time.ctime(self._tc_start)
71 self._cdir = os.getcwd()
75 Gives short application path (the complete path is $HOME/$APPLI)
77 return os.environ.get("APPLI",".salome_"+versnb)
80 file = open(os.path.join(os.environ["KERNEL_ROOT_DIR"],"bin","salome","VERSION"), "r")
82 versnb = string.strip(string.split(s, ":")[1])
83 dirname=".salome_"+versnb
91 Gives salome version number