ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
PyUtils
bin
pool_extractFileIdentifier.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
5
# @file: pool_extractFileIdentifier.py
6
# @purpose: extract the GUID of a POOL file.
7
# Also speeds up greatly processing time by shrinking LD_LIBRARY_PATH
8
# @author: Sebastien Binet <binet@cern.ch>
9
# @date: March 2009
10
#
11
# @example:
12
#
13
# python pool_extractFileIdentifier.py aod.pool.root
14
#
15
# if pool_extractFileIdentifier.py has been made 'chmod +x' one can just do:
16
# ./pool_extractFileIdentifier.py aod.pool.root
17
18
def
pool_extract
(files):
19
print
(
":: extracting GUID for [%i] files... "
% len(files))
20
import
os
21
import
subprocess
22
sc,exe = subprocess.getstatusoutput(
'which pool_extractFileIdentifier'
)
23
if
sc != 0:
24
print
(
":: could not find 'pool_extractFileIdentifier' !"
)
25
print
(exe)
26
return
1
27
28
cmd =
"%s %s"
% (exe,
" "
.join(files))
29
sc, out = subprocess.getstatusoutput(cmd)
30
31
out = os.linesep.join(
32
[o
for
o
in
out.splitlines()
33
if
not
(o.startswith(
"Warning in <TClass::TClass>: no dictionary for class "
)
or
34
o.startswith(
'Warning in <TEnvRec::ChangeValue>: duplicate entry'
))]
35
)
36
37
if
sc != 0:
38
print
(
":: problem running pool_extractFileIdentifier:"
)
39
print
(out)
40
return
sc
41
42
print
(out)
43
print
(
":: extracting GUID for [%i] files... [done]"
% len(files))
44
return
sc
45
46
if
__name__ ==
"__main__"
:
47
import
sys
48
from
optparse
import
OptionParser
49
parser = OptionParser(usage=
"%prog file1.pool [file2.pool [...]]"
)
50
parser.add_option(
"-f"
,
"--files"
,
51
dest =
"files"
,
52
help =
"(list of) files to extract the GUID(s) from"
)
53
options, args = parser.parse_args()
54
55
files = list()
56
if
len(args) > 0:
57
files = [ arg
for
arg
in
args
if
arg[0] !=
"-"
]
58
pass
59
60
if
options.files
is
None
and
len(files) == 0:
61
str(parser.print_help()
or
""
)
62
print
(
":: You have to provide at least one POOL file to extract a GUID from:"
)
63
print
(
" shell> pool_extractFileIdentifier.py aod.pool"
)
64
sys.exit(1)
65
66
if
options.files
is
not
None
:
67
import
os
68
for
f
in
options.files.split():
69
f = os.path.expandvars(os.path.expanduser(f))
70
files.append(f)
71
72
sys.exit(
pool_extract
(files=files))
pool_extractFileIdentifier.pool_extract
pool_extract(files)
Definition
pool_extractFileIdentifier.py:18
Generated on
for ATLAS Offline Software by
1.17.0