llversion.py

Go to the documentation of this file.
00001 """@file llversion.py
00002 @brief Utility for parsing llcommon/llversion${server}.h
00003        for the version string and channel string
00004        Utility that parses svn info for branch and revision
00005 
00006 $LicenseInfo:firstyear=2006&license=mit$
00007 
00008 Copyright (c) 2006-2008, Linden Research, Inc.
00009 
00010 Permission is hereby granted, free of charge, to any person obtaining a copy
00011 of this software and associated documentation files (the "Software"), to deal
00012 in the Software without restriction, including without limitation the rights
00013 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00014 copies of the Software, and to permit persons to whom the Software is
00015 furnished to do so, subject to the following conditions:
00016 
00017 The above copyright notice and this permission notice shall be included in
00018 all copies or substantial portions of the Software.
00019 
00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00026 THE SOFTWARE.
00027 $/LicenseInfo$
00028 """
00029 
00030 import re, sys, os, commands
00031 
00032 # Methods for gathering version information from
00033 # llversionviewer.h and llversionserver.h
00034 
00035 def get_src_root():
00036     indra_lib_python_indra_path = os.path.dirname(__file__)
00037     return os.path.abspath(os.path.realpath(indra_lib_python_indra_path + "/../../../../../"))
00038 
00039 def get_version_file_contents(version_type):
00040     filepath = get_src_root() + '/indra/llcommon/llversion%s.h' % version_type
00041     file = open(filepath,"r")
00042     file_str = file.read()
00043     file.close()
00044     return file_str
00045 
00046 def get_version(version_type):
00047     file_str = get_version_file_contents(version_type)
00048     m = re.search('const S32 LL_VERSION_MAJOR = (\d+);', file_str)
00049     VER_MAJOR = m.group(1)
00050     m = re.search('const S32 LL_VERSION_MINOR = (\d+);', file_str)
00051     VER_MINOR = m.group(1)
00052     m = re.search('const S32 LL_VERSION_PATCH = (\d+);', file_str)
00053     VER_PATCH = m.group(1)
00054     m = re.search('const S32 LL_VERSION_BUILD = (\d+);', file_str)
00055     VER_BUILD = m.group(1)
00056     version = "%(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s" % locals()
00057     return version
00058 
00059 def get_channel(version_type):
00060     file_str = get_version_file_contents(version_type)
00061     m = re.search('const char \* const LL_CHANNEL = "(.+)";', file_str)
00062     return m.group(1)
00063     
00064 def get_viewer_version():
00065     return get_version('viewer')
00066 
00067 def get_server_version():
00068     return get_version('server')
00069 
00070 def get_viewer_channel():
00071     return get_channel('viewer')
00072 
00073 def get_server_channel():
00074     return get_channel('server')
00075 
00076 # Methods for gathering subversion information
00077 def get_svn_status_matching(regular_expression):
00078     # Get the subversion info from the working source tree
00079     status, output = commands.getstatusoutput('svn info %s' % get_src_root())
00080     m = regular_expression.search(output)
00081     if not m:
00082         print "Failed to parse svn info output, resultfollows:"
00083         print output
00084         raise Exception, "No matching svn status in "+src_root
00085     return m.group(1)
00086 
00087 def get_svn_branch():
00088     branch_re = re.compile('URL: (\S+)')
00089     return get_svn_status_matching(branch_re)
00090 
00091 def get_svn_revision():
00092     last_rev_re = re.compile('Last Changed Rev: (\d+)')
00093     return get_svn_status_matching(last_rev_re)
00094 
00095 

Generated on Fri May 16 08:31:53 2008 for SecondLife by  doxygen 1.5.5