ATLAS Offline Software
Functions
python.utility.revision_checking Namespace Reference

Functions

def check_svn_revision (path)
 

Function Documentation

◆ check_svn_revision()

def python.utility.revision_checking.check_svn_revision (   path)
Infer used SVN code revision.

@param path location of the code whose SVN revision will be checked.

If the target path is not an SVN repository, a manually maintained text file database of revisions will be
consulted as a fallback.

If neither the SVN check nor the fallback solution finds a revision, 'unknown' will be returned.

@author Stefan Richter  <stefan.richter@cern.ch>

Definition at line 6 of file revision_checking.py.

6 def check_svn_revision(path):
7  """
8  Infer used SVN code revision.
9 
10  @param path location of the code whose SVN revision will be checked.
11 
12  If the target path is not an SVN repository, a manually maintained text file database of revisions will be
13  consulted as a fallback.
14 
15  If neither the SVN check nor the fallback solution finds a revision, 'unknown' will be returned.
16 
17  @author Stefan Richter <stefan.richter@cern.ch>
18  """
19  try:
20  # Try getting the revision hash from the SVN repository
21  command = "svn info {path}".format(path=os.path.realpath(path)) # expand symbolic links
22  p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
23  (svninfo, _) = p.communicate()
24  for line in svninfo.split('\n'):
25  if "Revision:" in line:
26  return line.split()[-1]
27  except Exception:
28  # If it fails for whatever reason, ignore it
29  pass
30  try:
31  # As a fallback solution, try to read the revision from a text database
32  with open(os.path.join(os.environ["POWHEGPATH"], "ProcessRevisions.txt"), "r") as dbfile:
33  for line in dbfile:
34  tokens = line.split(" : ")
35  if tokens[0] == os.path.basename(path): # found the process of interest
36  return tokens[1][1:] # return the revision number without the leading 'r'
37  except Exception:
38  # If it fails for whatever reason, ignore it
39  pass
40  # Neither method of getting the revision hash worked, so it is marked as "unknown"
41  return "unknown"
python.utility.revision_checking.check_svn_revision
def check_svn_revision(path)
Definition: revision_checking.py:6
vtune_athena.format
format
Definition: vtune_athena.py:14
Trk::open
@ open
Definition: BinningType.h:40