Package buildbot
[frames] | no frames]

Source Code for Package buildbot

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  from __future__ import with_statement 
17   
18  # strategy: 
19  # 
20  # if there is a VERSION file, use its contents. otherwise, call git to 
21  # get a version string. if that also fails, use 'latest'. 
22  # 
23  import os 
24   
25  version = "latest" 
26   
27  try: 
28      fn = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION') 
29      with open(fn) as f: 
30          version = f.read().strip() 
31   
32  except IOError: 
33      from subprocess import Popen, PIPE, STDOUT 
34      import re 
35   
36      VERSION_MATCH = re.compile(r'\d+\.\d+\.\d+(\w|-)*') 
37   
38      try: 
39          dir  = os.path.dirname(os.path.abspath(__file__)) 
40          p = Popen(['git', 'describe', '--tags', '--always'], cwd=dir, stdout=PIPE, stderr=STDOUT) 
41          out = p.communicate()[0] 
42   
43          if (not p.returncode) and out: 
44              v = VERSION_MATCH.search(out) 
45              if v: 
46                  version = v.group() 
47      except OSError: 
48          pass 
49