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 # Dependencies. 26 import dep_check 27 28 # Python module imports. 29 from os import F_OK, access, sep 30 from re import search 31 PIPE, Popen = None, None 32 if dep_check.subprocess_module: 33 from subprocess import PIPE, Popen 34 35 # relax module imports. 36 import lib.structure.internal.object 37 from status import Status; status = Status() 38 39 40 version = "3.2.3" 41 repo_revision = None 42 repo_url = None 43 4446 """Determine the subversion revision number and URL from svn or git-svn copies of the repository.""" 47 48 # The global variables 49 global repo_revision 50 global repo_url 51 52 # The variables are already set, so do nothing. 53 if repo_revision != None or repo_url != None: 54 return 55 56 # Python 2.3 and earlier. 57 if Popen == None: 58 return 59 60 # The command to use. 61 cmd = None 62 if access(status.install_path+sep+'.svn', F_OK): 63 cmd = 'svn info %s' % status.install_path 64 elif access(status.install_path+sep+'.git', F_OK): 65 cmd = 'cd %s; git svn info' % status.install_path 66 67 # Not a repository copy, so do nothing. 68 if not cmd: 69 return 70 71 # Open the pipe and run the command. 72 pipe = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=False) 73 74 # Loop over the output lines. 75 for line in pipe.stdout.readlines(): 76 # Decode Python 3 byte arrays. 77 if hasattr(line, 'decode'): 78 line = line.decode() 79 80 # Split up the line. 81 row = line.split() 82 83 # Store revision as the global variable. 84 if len(row) and row[0] == 'Revision:': 85 repo_revision = str(row[1]) 86 87 # Store URL as the global variable. 88 if len(row) and row[0] == 'URL:': 89 repo_url = str(row[1])90 9193 """Return the full relax version, including all SVN info for repository versions. 94 95 @return: The relax version string. 96 @rtype: str 97 """ 98 99 # The relax version. 100 ver = version 101 102 # Repository version. 103 if ver == 'repository checkout': 104 # The global variables 105 global repo_revision 106 global repo_url 107 108 # Change the version string. 109 if repo_revision != None: 110 ver = version + " r" + repo_revision 111 if repo_url != None: 112 ver = ver + " " + repo_url 113 114 # Return the version. 115 return ver116 117 118 # Fetch the repository information, if present. 119 repo_information() 120 121 # Set the version in the relax internal structural object. 122 lib.structure.internal.object.RELAX_VERSION = version_full() 123
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Jul 3 13:38:53 2014 | http://epydoc.sourceforge.net |