ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tools
PyUtils
bin
pool_insertFileToCatalog.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_insertFileToCatalog.py
6
# @purpose: insert a POOL file into a POOL file catalog without displaying the
7
# annoying ROOT warnings for missing dictionaries
8
# Also speeds up greatly processing time by shrinking LD_LIBRARY_PATH
9
# @author: Sebastien Binet <binet@cern.ch>
10
# @date: May 2006
11
#
12
# @example:
13
#
14
# python pool_insertFileToCatalog.py aod.pool.root
15
#
16
# if pool_insertFileToCatalog.py has been made 'chmod +x' one can just do:
17
# ./pool_insertFileToCatalog.py aod.pool.root
18
19
def
pool_insert
(files, catalog_name="xmlcatalog_file:PoolFileCatalog.xml
"):
20
print
(
":: inserting [%i] files into pool catalog... (%s)"
%(
21
len (files),
22
catalog_name
23
))
24
import
os
25
import
subprocess
26
sc,exe = subprocess.getstatusoutput (
'which pool_insertFileToCatalog'
)
27
if
sc != 0:
28
print
(
":: could not find 'pool_insertFileToCatalog' !"
)
29
print
(exe)
30
return
1
31
32
os.environ[
'POOL_CATALOG'
] = catalog_name
33
cmd =
"%s %s"
% (exe,
" "
.join(files))
34
sc, out = subprocess.getstatusoutput (cmd)
35
36
out = os.linesep.join(
37
[o
for
o
in
out.splitlines()
38
if
not
(o.startswith(
"Warning in <TClass::TClass>: no dictionary for class "
)
or
39
o.startswith(
'Warning in <TEnvRec::ChangeValue>: duplicate entry'
))]
40
)
41
42
if
sc != 0:
43
print
(
":: problem running pool_insertFileToCatalog:"
)
44
print
(out)
45
return
2
46
47
print
(out)
48
print
(
":: inserting [%i] files into pool catalog... [done]"
%len(files))
49
return
sc
50
51
if
__name__ ==
"__main__"
:
52
import
sys
53
from
optparse
import
OptionParser
54
parser = OptionParser(usage=
"%prog file1.pool [file2.pool [...]] [--catalog='xmlcatalog_file:PoolFileCatalog.xml']"
)
55
parser.add_option(
"-f"
,
"--files"
,
56
dest =
"files"
,
57
help =
"(list of) files to be inserted in the catalog"
)
58
parser.add_option(
"--catalog"
,
59
dest =
"catalog"
,
60
default =
"xmlcatalog_file:PoolFileCatalog.xml"
,
61
help =
"catalog connection string"
)
62
options, args = parser.parse_args()
63
64
files = list()
65
if
len(args) > 0:
66
files = [ arg
for
arg
in
args
if
arg[0] !=
"-"
]
67
pass
68
69
if
options.files
is
None
and
len(files) == 0:
70
str(parser.print_help()
or
""
)
71
print
(
":: You have to provide at least one POOL file to insert:"
)
72
print
(
" shell> pool_insertFileToCatalog.py aod.pool"
)
73
sys.exit(1)
74
75
if
options.files
is
not
None
:
76
import
os
77
for
f
in
options.files.split():
78
f = os.path.expandvars(os.path.expanduser(f))
79
files.append(f)
80
81
sc =
pool_insert
(files=files, catalog_name=options.catalog)
82
sys.exit(sc)
pool_insertFileToCatalog.pool_insert
pool_insert(files, catalog_name="xmlcatalog_file:PoolFileCatalog.xml")
Definition
pool_insertFileToCatalog.py:19
Generated on
for ATLAS Offline Software by
1.17.0