1 # -*- coding: iso-8859-1 -*-
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 # File : salome_version.py
24 # Author : Vadim SANDLER
29 def getVersion( mod = "KERNEL" ):
31 Get SALOME module version number
32 Returns: version number string or None if VERSION file is not found
34 global _salome_versions
36 if not _salome_versions.has_key( mod ):
37 _salome_versions[ mod ] = None
39 root_dir = os.getenv( "%s_ROOT_DIR" % mod )
42 filename = root_dir + "/bin/salome/VERSION"
43 if not os.path.exists( filename ):
44 filename = root_dir + "/bin/VERSION"
45 file = open( filename )
48 _salome_versions[ mod ] = ver.split( ":" )[ -1 ].strip()
51 return _salome_versions[ mod ]
53 def getVersionMajor( mod = "KERNEL" ):
55 Get SALOME module major version number
56 Returns: version major number string or None if VERSION file is not found
58 ver = getVersion( mod )
60 return ver.split( "." )[ 0 ]
65 def getVersionMinor( mod = "KERNEL" ):
67 Get SALOME module minor version number
68 Returns: version minor number string or None if VERSION file is not found
70 ver = getVersion( mod )
72 return ver.split( "." )[ 1 ]
77 def getVersionRelease( mod = "KERNEL" ):
79 Get SALOME module release version number
80 Returns: version release number string or None if VERSION file is not found
82 ver = getVersion( mod )
84 return ver.split( "." )[ 2 ]
89 def getVersions( mod = "KERNEL" ):
91 Get SALOME module version as list of [major, minor, release] numbers
92 Returns: version numbers list
95 major = int( getVersionMajor( mod ) )
100 minor = int( getVersionMinor( mod ) )
105 rel = int( getVersionRelease( mod ) )
109 return [ major, minor, rel ]