Annotation of /trunk/indra/lib/python/indra/util/llversion.py
Parent Directory
|
Revision Log
Revision 137 - (view) (download) (as text)
| 1 : | mjm | 135 | """@file llversion.py |
| 2 : | @brief Utility for parsing llcommon/llversion${server}.h | ||
| 3 : | for the version string and channel string | ||
| 4 : | Utility that parses svn info for branch and revision | ||
| 5 : | |||
| 6 : | $LicenseInfo:firstyear=2006&license=mit$ | ||
| 7 : | |||
| 8 : | mjm | 137 | Copyright (c) 2006-2010, Linden Research, Inc. |
| 9 : | mjm | 135 | |
| 10 : | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 11 : | of this software and associated documentation files (the "Software"), to deal | ||
| 12 : | in the Software without restriction, including without limitation the rights | ||
| 13 : | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 14 : | copies of the Software, and to permit persons to whom the Software is | ||
| 15 : | furnished to do so, subject to the following conditions: | ||
| 16 : | |||
| 17 : | The above copyright notice and this permission notice shall be included in | ||
| 18 : | all copies or substantial portions of the Software. | ||
| 19 : | |||
| 20 : | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 21 : | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 22 : | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 23 : | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 24 : | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 25 : | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 26 : | THE SOFTWARE. | ||
| 27 : | $/LicenseInfo$ | ||
| 28 : | """ | ||
| 29 : | |||
| 30 : | import re, sys, os, commands | ||
| 31 : | |||
| 32 : | # Methods for gathering version information from | ||
| 33 : | # llversionviewer.h and llversionserver.h | ||
| 34 : | |||
| 35 : | def get_src_root(): | ||
| 36 : | indra_lib_python_indra_path = os.path.dirname(__file__) | ||
| 37 : | return os.path.abspath(os.path.realpath(indra_lib_python_indra_path + "/../../../../../")) | ||
| 38 : | |||
| 39 : | def get_version_file_contents(version_type): | ||
| 40 : | filepath = get_src_root() + '/indra/llcommon/llversion%s.h' % version_type | ||
| 41 : | file = open(filepath,"r") | ||
| 42 : | file_str = file.read() | ||
| 43 : | file.close() | ||
| 44 : | return file_str | ||
| 45 : | |||
| 46 : | def get_version(version_type, revision=0): | ||
| 47 : | file_str = get_version_file_contents(version_type) | ||
| 48 : | m = re.search('const S32 LL_VERSION_MAJOR = (\d+);', file_str) | ||
| 49 : | VER_MAJOR = m.group(1) | ||
| 50 : | m = re.search('const S32 LL_VERSION_MINOR = (\d+);', file_str) | ||
| 51 : | VER_MINOR = m.group(1) | ||
| 52 : | m = re.search('const S32 LL_VERSION_PATCH = (\d+);', file_str) | ||
| 53 : | VER_PATCH = m.group(1) | ||
| 54 : | if revision > 0: | ||
| 55 : | VER_BUILD = revision | ||
| 56 : | else: | ||
| 57 : | m = re.search('const S32 LL_VERSION_BUILD = (\d+);', file_str) | ||
| 58 : | VER_BUILD = m.group(1) | ||
| 59 : | version = "%(VER_MAJOR)s.%(VER_MINOR)s.%(VER_PATCH)s.%(VER_BUILD)s" % locals() | ||
| 60 : | return version | ||
| 61 : | |||
| 62 : | def get_channel(version_type): | ||
| 63 : | file_str = get_version_file_contents(version_type) | ||
| 64 : | m = re.search('const char \* const LL_CHANNEL = "(.+)";', file_str) | ||
| 65 : | return m.group(1) | ||
| 66 : | |||
| 67 : | def get_viewer_version(revision=0): | ||
| 68 : | return get_version('viewer', revision) | ||
| 69 : | |||
| 70 : | def get_server_version(revision=0): | ||
| 71 : | return get_version('server', revision) | ||
| 72 : | |||
| 73 : | def get_viewer_channel(): | ||
| 74 : | return get_channel('viewer') | ||
| 75 : | |||
| 76 : | def get_server_channel(): | ||
| 77 : | return get_channel('server') | ||
| 78 : | |||
| 79 : | # Methods for gathering subversion information | ||
| 80 : | def get_svn_status_matching(regular_expression): | ||
| 81 : | # Get the subversion info from the working source tree | ||
| 82 : | status, output = commands.getstatusoutput('svn info %s' % get_src_root()) | ||
| 83 : | m = regular_expression.search(output) | ||
| 84 : | if not m: | ||
| 85 : | print "Failed to parse svn info output, resultfollows:" | ||
| 86 : | print output | ||
| 87 : | raise Exception, "No matching svn status in "+src_root | ||
| 88 : | return m.group(1) | ||
| 89 : | |||
| 90 : | def get_svn_branch(): | ||
| 91 : | branch_re = re.compile('URL: (\S+)') | ||
| 92 : | return get_svn_status_matching(branch_re) | ||
| 93 : | |||
| 94 : | def get_svn_revision(): | ||
| 95 : | last_rev_re = re.compile('Last Changed Rev: (\d+)') | ||
| 96 : | return get_svn_status_matching(last_rev_re) | ||
| 97 : | |||
| 98 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

