18 from __future__
import with_statement, print_function
20 from future
import standard_library
21 standard_library.install_aliases()
23 def pool_insert(files, catalog_name="xmlcatalog_file:PoolFileCatalog.xml
"):
24 print (
":: inserting [%i] files into pool catalog... (%s)"%(
30 sc,exe = subprocess.getstatusoutput (
'which pool_insertFileToCatalog')
32 print (
":: could not find 'pool_insertFileToCatalog' !")
36 os.environ[
'POOL_CATALOG'] = catalog_name
37 cmd =
"%s %s" % (exe,
" ".
join(files))
38 sc, out = subprocess.getstatusoutput (cmd)
40 out = os.linesep.join(
41 [o
for o
in out.splitlines()
42 if not (o.startswith(
"Warning in <TClass::TClass>: no dictionary for class ")
or
43 o.startswith(
'Warning in <TEnvRec::ChangeValue>: duplicate entry'))]
47 print (
":: problem running pool_insertFileToCatalog:")
52 print (
":: inserting [%i] files into pool catalog... [done]"%len(files))
55 if __name__ ==
"__main__":
57 from optparse
import OptionParser
58 parser = OptionParser(usage=
"%prog file1.pool [file2.pool [...]] [--catalog='xmlcatalog_file:PoolFileCatalog.xml']")
59 parser.add_option(
"-f",
"--files",
61 help =
"(list of) files to be inserted in the catalog")
62 parser.add_option(
"--catalog",
64 default =
"xmlcatalog_file:PoolFileCatalog.xml",
65 help =
"catalog connection string")
66 options, args = parser.parse_args()
70 files = [ arg
for arg
in args
if arg[0] !=
"-" ]
73 if options.files
is None and len(files) == 0:
74 str(parser.print_help()
or "")
75 print (
":: You have to provide at least one POOL file to insert:")
76 print (
" shell> pool_insertFileToCatalog.py aod.pool")
79 if not (options.files
is None):
81 for f
in options.files.split():
82 f = os.path.expandvars(os.path.expanduser(f))