1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # File : salome_version.py
23 # Author : Vadim SANDLER
28 def getVersion( mod = "KERNEL" ):
30 Get SALOME module version number
31 Returns: version number string or None if VERSION file is not found
33 global _salome_versions
35 if not _salome_versions.has_key( mod ):
36 _salome_versions[ mod ] = None
38 root_dir = os.getenv( "%s_ROOT_DIR" % mod )
41 filename = root_dir + "/bin/salome/VERSION"
42 if not os.path.exists( filename ):
43 filename = root_dir + "/bin/VERSION"
44 file = open( filename )
47 _salome_versions[ mod ] = ver.split( ":" )[ -1 ].strip()
50 return _salome_versions[ mod ]
52 def getVersionMajor( mod = "KERNEL" ):
54 Get SALOME module major version number
55 Returns: version major number string or None if VERSION file is not found
57 ver = getVersion( mod )
59 return ver.split( "." )[ 0 ]
64 def getVersionMinor( mod = "KERNEL" ):
66 Get SALOME module minor version number
67 Returns: version minor number string or None if VERSION file is not found
69 ver = getVersion( mod )
71 return ver.split( "." )[ 1 ]
76 def getVersionRelease( mod = "KERNEL" ):
78 Get SALOME module release version number
79 Returns: version release number string or None if VERSION file is not found
81 ver = getVersion( mod )
83 return ver.split( "." )[ 2 ]
88 def getVersions( mod = "KERNEL" ):
90 Get SALOME module version as list of [major, minor, release] numbers
91 Returns: version numbers list
94 major = int( getVersionMajor( mod ) )
99 minor = int( getVersionMinor( mod ) )
104 rel = int( getVersionRelease( mod ) )
108 return [ major, minor, rel ]