Skip to content
Snippets Groups Projects
Commit 4d5e6852 authored by Ewelina Maria Lobodzinska's avatar Ewelina Maria Lobodzinska
Browse files

Merge branch 'powhegcontrol_fix_revision_checking' into '21.6'

Revise Powheg SVN revision checking in PowhegControl

See merge request atlas/athena!23439
parents e885096f fafb460d
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
import os
import subprocess
def check_svn_revision(path):
"""! Infer used SVN code revision.
"""
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>
"""
command = "svn info {path}".format(path=os.path.realpath(path)) # expand symbolic links
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(svninfo, _) = p.communicate()
for line in svninfo.split('\n'):
if "Revision:" in line:
return line.split()[-1]
try:
# Try getting the revision hash from the SVN repository
command = "svn info {path}".format(path=os.path.realpath(path)) # expand symbolic links
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(svninfo, _) = p.communicate()
for line in svninfo.split('\n'):
if "Revision:" in line:
return line.split()[-1]
except:
# If it fails for whatever reason, ignore it
pass
try:
# As a fallback solution, try to read the revision from a text database
with open("/afs/cern.ch/atlas/offline/external/powhegbox/ATLASOTF-00-03-13/ProcessRevisions.txt", "r") as dbfile:
with open(os.path.join(os.environ["POWHEGPATH"], "ProcessRevisions.txt"), "r") as dbfile:
for line in dbfile:
tokens = line.split(" : ")
if tokens[0] == os.path.basename(path): # found the process of interest
return tokens[1][1:] # return the revision number without the leading 'r'
except:
# If it fails for whatever reason, ignore it
pass
# Neither method of getting the revision hash worked, so it is marked as "unknown"
return "unknown"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment