ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
PowhegControl
python
utility
revision_checking.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3
import
os
4
import
subprocess
5
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
check_svn_revision(path)
Definition
revision_checking.py:6
Generated on
for ATLAS Offline Software by
1.17.0