Commit 36143132a75270b1422ef5c28adfcedea9ce2420

Authored by tatiana
1 parent 8e5e0d4f

ADD: Source code svn version support

.gitattributes
... ... @@ -142,6 +142,7 @@ invesalius/reader/dicom_grouper.py -text
142 142 invesalius/reader/dicom_reader.py -text
143 143 invesalius/session.py -text
144 144 invesalius/utils.py -text
  145 +invesalius/version.py -text
145 146 presets/raycasting/Airways[!!-~]II.plist -text
146 147 presets/raycasting/Airways.plist -text
147 148 presets/raycasting/Black[!!-~]&[!!-~]White.plist -text
... ...
invesalius/project.py
... ... @@ -24,6 +24,7 @@ import wx.lib.pubsub as ps
24 24  
25 25 from utils import Singleton
26 26 from presets import Presets
  27 +import version
27 28  
28 29 class Project(object):
29 30 # Only one project will be initialized per time. Therefore, we use
... ... @@ -87,10 +88,10 @@ class Project(object):
87 88 # The raycasting preset setted in this project
88 89 self.raycasting_preset = ''
89 90  
90   - self.debug = 0
91   - self.version = "$Revision$"
  91 + self.invesalius_version = version.get_svn_revision()
  92 + print self.invesalius_version
92 93  
93   - print self.version
  94 + self.debug = 0
94 95  
95 96 ####### MASK OPERATIONS
96 97  
... ...
invesalius/version.py 0 → 100644
... ... @@ -0,0 +1,66 @@
  1 +#--------------------------------------------------------------------------
  2 +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas
  3 +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer
  4 +# Homepage: http://www.softwarepublico.gov.br
  5 +# Contact: invesalius@cti.gov.br
  6 +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt)
  7 +#--------------------------------------------------------------------------
  8 +# Este programa e software livre; voce pode redistribui-lo e/ou
  9 +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme
  10 +# publicada pela Free Software Foundation; de acordo com a versao 2
  11 +# da Licenca.
  12 +#
  13 +# Este programa eh distribuido na expectativa de ser util, mas SEM
  14 +# QUALQUER GARANTIA; sem mesmo a garantia implicita de
  15 +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM
  16 +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
  17 +# detalhes.
  18 +#--------------------------------------------------------------------------
  19 +
  20 +# This file is based on Django code (version 10377):
  21 +# django/trunk/django/utils/version.py
  22 +# Available at http://code.djangoproject.com/
  23 +
  24 +import os
  25 +import os.path
  26 +import re
  27 +
  28 +def get_svn_revision(path=None):
  29 + """
  30 + Returns the SVN revision in the form SVN-XXXX,
  31 + where XXXX is the revision number.
  32 +
  33 + Returns SVN-unknown if anything goes wrong, such as an unexpected
  34 + format of internal SVN files.
  35 +
  36 + If path is provided, it should be a directory whose SVN info you want to
  37 + inspect. If it's not provided, this will use the current
  38 + directory.
  39 + """
  40 + rev = None
  41 + if path is None:
  42 + path = os.curdir
  43 + entries_path = '%s/.svn/entries' % path
  44 +
  45 + try:
  46 + entries = open(entries_path, 'r').read()
  47 + except IOError:
  48 + pass
  49 + else:
  50 + # Versions >= 7 of the entries file are flat text. The first line is
  51 + # the version number. The next set of digits after 'dir' is the revision.
  52 + if re.match('(\d+)', entries):
  53 + rev_match = re.search('\d+\s+dir\s+(\d+)', entries)
  54 + if rev_match:
  55 + rev = rev_match.groups()[0]
  56 + # Older XML versions of the file specify revision as an attribute of
  57 + # the first entries node.
  58 + else:
  59 + from xml.dom import minidom
  60 + dom = minidom.parse(entries_path)
  61 + rev = dom.getElementsByTagName('entry')[0].getAttribute('revision')
  62 +
  63 + if rev:
  64 + return 'pspb-%s' % rev
  65 + return 'pspb-unknown'
  66 +
... ...