2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2008 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.
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
24 # File : salome_version.py
25 # Author : Vadim SANDLER
30 def getVersion( mod = "KERNEL" ):
32 Get SALOME module version number
33 Returns: version number string or None if VERSION file is not found
35 global _salome_versions
37 if not _salome_versions.has_key( mod ):
38 _salome_versions[ mod ] = None
40 root_dir = os.getenv( "%s_ROOT_DIR" % mod )
43 filename = root_dir + "/bin/salome/VERSION"
44 if not os.path.exists( filename ):
45 filename = root_dir + "/bin/VERSION"
46 file = open( filename )
49 _salome_versions[ mod ] = ver.split( ":" )[ -1 ].strip()
52 return _salome_versions[ mod ]
54 def getVersionMajor( mod = "KERNEL" ):
56 Get SALOME module major version number
57 Returns: version major number string or None if VERSION file is not found
59 ver = getVersion( mod )
61 return ver.split( "." )[ 0 ]
66 def getVersionMinor( mod = "KERNEL" ):
68 Get SALOME module minor version number
69 Returns: version minor number string or None if VERSION file is not found
71 ver = getVersion( mod )
73 return ver.split( "." )[ 1 ]
78 def getVersionRelease( mod = "KERNEL" ):
80 Get SALOME module release version number
81 Returns: version release number string or None if VERSION file is not found
83 ver = getVersion( mod )
85 return ver.split( "." )[ 2 ]
90 def getVersions( mod = "KERNEL" ):
92 Get SALOME module version as list of [major, minor, release] numbers
93 Returns: version numbers list
96 major = int( getVersionMajor( mod ) )
101 minor = int( getVersionMinor( mod ) )
106 rel = int( getVersionRelease( mod ) )
110 return [ major, minor, rel ]