Package eoxserver
[hide private]
[frames] | no frames]

Source Code for Package eoxserver

 1  #------------------------------------------------------------------------------- 
 2  # $Id: __init__.py 2372 2013-03-15 20:07:59Z meissls $ 
 3  # 
 4  # Project: EOxServer <http://eoxserver.org> 
 5  # Authors: Stephan Krause <stephan.krause@eox.at> 
 6  #          Stephan Meissl <stephan.meissl@eox.at> 
 7  #          Fabian Schindler <fabian.schindler@eox.at> 
 8  # 
 9  #------------------------------------------------------------------------------- 
10  # Copyright (C) 2011 EOX IT Services GmbH 
11  # 
12  # Permission is hereby granted, free of charge, to any person obtaining a copy 
13  # of this software and associated documentation files (the "Software"), to deal 
14  # in the Software without restriction, including without limitation the rights 
15  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
16  # copies of the Software, and to permit persons to whom the Software is  
17  # furnished to do so, subject to the following conditions: 
18  # 
19  # The above copyright notice and this permission notice shall be included in all 
20  # copies of this Software or works derived from this Software. 
21  # 
22  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
23  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
24  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
25  # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
26  # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
27  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
28  # THE SOFTWARE. 
29  #------------------------------------------------------------------------------- 
30   
31  import re 
32   
33   
34  VERSION = (0, 4, None, 'dev', 0) 
35  #VERSION = (0, 4, None, 'alpha', 1) 
36  #VERSION = (0, 4, None, 'beta', 1) 
37  #VERSION = (0, 4, None, 'rc', 1) 
38  #VERSION = (0, 4, 0, 'final', 0) 
39  SVN_REV = '$Id: __init__.py 2372 2013-03-15 20:07:59Z meissls $' 
40   
41 -def get_svn_revision(path=None):
42 """ 43 Returns the SVN revision in the form SVN-XXXX, 44 where XXXX is the revision number. 45 46 Returns SVN-unknown if anything goes wrong, such as an unexpected 47 format of internal SVN files. 48 49 If path is provided, it should be a directory whose SVN info you want to 50 inspect. If it's not provided, this will use the root django/ package 51 directory. 52 """ 53 rev = None 54 if path is None: 55 path = __path__[0] 56 entries_path = '%s/.svn/entries' % path 57 58 try: 59 entries = open(entries_path, 'r').read() 60 except IOError: 61 pass 62 else: 63 # Versions >= 7 of the entries file are flat text. The first line is 64 # the version number. The next set of digits after 'dir' is the revision. 65 if re.match('(\d+)', entries): 66 rev_match = re.search('\d+\s+dir\s+(\d+)', entries) 67 if rev_match: 68 rev = rev_match.groups()[0] 69 # Older XML versions of the file specify revision as an attribute of 70 # the first entries node. 71 else: 72 from xml.dom import minidom 73 dom = minidom.parse(entries_path) 74 rev = dom.getElementsByTagName('entry')[0].getAttribute('revision') 75 76 if rev: 77 return u'SVN-%s' % rev 78 return u'SVN-unknown'
79 80
81 -def get_version():
82 version = '%s.%s' % (VERSION[0], VERSION[1]) 83 if VERSION[2] != None: 84 version = '%s.%s' % (version, VERSION[2]) 85 if VERSION[3:] == ('dev', 0): 86 version = "%sdev" % version 87 svn_rev = get_svn_revision(".") 88 if svn_rev != u'SVN-unknown': 89 version = "%s-%s" % (version, svn_rev) 90 else: 91 if VERSION[3] != 'final': 92 version = '%s%s%s' % (version, VERSION[3], VERSION[4]) 93 94 return version
95