Trees | Indices | Help |
|
---|
|
1 ############################################################################### 2 # # 3 # Copyright (C) 2009-2014 Edward d'Auvergne # 4 # # 5 # This file is part of the program relax (http://www.nmr-relax.com). # 6 # # 7 # This program is free software: you can redistribute it and/or modify # 8 # it under the terms of the GNU General Public License as published by # 9 # the Free Software Foundation, either version 3 of the License, or # 10 # (at your option) any later version. # 11 # # 12 # This program is distributed in the hope that it will be useful, # 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 # GNU General Public License for more details. # 16 # # 17 # You should have received a copy of the GNU General Public License # 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. # 19 # # 20 ############################################################################### 21 22 # Module docstring. 23 """Module for relax version information.""" 24 25 # Python module imports. 26 from os import F_OK, access, sep 27 try: 28 from subprocess import PIPE, Popen 29 except ImportError: 30 PIPE, Popen = None, None 31 32 # relax module imports. 33 import lib.structure.internal.object 34 from status import Status; status = Status() 35 36 37 version = "3.3.9" 38 repo_revision = None 39 repo_url = None 40 4143 """Determine the subversion revision number and URL from svn or git-svn copies of the repository.""" 44 45 # The global variables 46 global repo_revision 47 global repo_url 48 49 # The variables are already set, so do nothing. 50 if repo_revision != None or repo_url != None: 51 return 52 53 # Python 2.3 and earlier. 54 if Popen == None: 55 return 56 57 # The command to use. 58 cmd = None 59 if access(status.install_path+sep+'.svn', F_OK): 60 cmd = 'svn info %s' % status.install_path 61 elif access(status.install_path+sep+'.git', F_OK): 62 cmd = 'cd %s; git svn info' % status.install_path 63 64 # Not a repository copy, so do nothing. 65 if not cmd: 66 return 67 68 # Open the pipe and run the command. 69 pipe = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False) 70 71 # Loop over the output lines. 72 for line in pipe.stdout.readlines(): 73 # Decode Python 3 byte arrays. 74 if hasattr(line, 'decode'): 75 line = line.decode() 76 77 # Split up the line. 78 row = line.split() 79 80 # Store revision as the global variable. 81 if len(row) and row[0] == 'Revision:': 82 repo_revision = str(row[1]) 83 84 # Store URL as the global variable. 85 if len(row) and row[0] == 'URL:': 86 repo_url = str(row[1])87 8890 """Return the full relax version, including all SVN info for repository versions. 91 92 @return: The relax version string. 93 @rtype: str 94 """ 95 96 # The relax version. 97 ver = version 98 99 # Repository version. 100 if ver == 'repository checkout': 101 # The global variables 102 global repo_revision 103 global repo_url 104 105 # Change the version string. 106 if repo_revision != None: 107 ver = version + " r" + repo_revision 108 if repo_url != None: 109 ver = ver + " " + repo_url 110 111 # Return the version. 112 return ver113 114 115 # Fetch the repository information, if present. 116 repo_information() 117 118 # Set the version in the relax internal structural object. 119 lib.structure.internal.object.RELAX_VERSION = version_full() 120
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Sep 30 14:41:40 2015 | http://epydoc.sourceforge.net |