17 from __future__
import with_statement
21 __version__ =
"$Revision: 1.4 $"
22 __author__ =
"Sebastien Binet <binet@cern.ch>"
24 a simple python script to run pyathena and use PySgDumper to dump
25 a (set of) event(s) from a POOL (esd/aod) file into an ASCII file\
28 from optparse
import OptionParser
30 import PyDumper.SgDumpLib
as SgDumpLib
33 """translate a string into a python slice
35 sl= [
int(s)
if s !=
'' else None for s
in slice_str.split(
':')]
38 assert len(sl)==3,
'invalid input slice string'
42 return slice (start, stop, step)
44 if __name__ ==
"__main__":
45 parser = OptionParser(
46 usage=
"usage: %prog [options] -o out.ascii in1.pool "\
47 "[in2.pool [in3.pool [...]]]"
49 _add = parser.add_option
54 help =
"Name of the output file which will contain the informations"\
55 " gathered during athena processing. These informations "\
56 "will be stored into an ascii file.")
62 help =
"list of events or event-max or (python) slice of events."\
63 " (dummy for now: only understand event-max syntax)")
69 help =
"number of events to skip.")
74 help =
"tell application to save the automatically generated "\
75 "joboption under some name for (mainly) debugging "\
76 "and/or customization purposes.")
80 action =
"store_true",
82 help =
"switch to enable the attempt at removing all the (temporary) files sg-dump produces during the course of its execution")
86 action =
"store_false",
87 help =
"switch to enable the attempt at removing all the (temporary) files sg-dump produces during the course of its execution")
92 help =
"space-separated list of athena command-line options. "\
93 "these will be passed to the validation job. (e.g. "\
94 "'--perfmon --stdcmalloc')" )
98 default =
"PyDumper.PyComps:PySgDumper",
99 help =
"name of the class to use to process the file(s) content (default: '%default'. validation uses: 'PyDumper.PyComps:DataProxyLoader')")
104 help =
"comma-separated list of type#key containers to dump (default: all)")
109 help =
"comma-separated list of glob patterns of keys/types to ignore")
111 _add(
"--conditions-tag",
112 dest =
"conditions_tag",
114 help =
"override setting of global conditions tag")
118 action =
"store_true",
120 help =
"preserve full log file")
122 (options, args) = parser.parse_args()
126 from AthenaCommon.Logging
import logging
127 msg = logging.getLogger (
'sg-dumper')
128 msg.setLevel (logging.INFO)
132 input_files = [arg
for arg
in args
if arg[0] !=
"-"]
135 if len(input_files) == 0
or options.oname
is None:
137 msg.error(
'please provide an output filename and '
138 'at least one input file')
143 sc, out = SgDumpLib.run_sg_dump(
145 output=options.oname,
148 dump_jobo=options.dump_jobo,
149 pyalg_cls=options.pyalg_cls,
150 include=options.include,
151 exclude=options.exclude,
152 do_clean_up=options.do_clean_up,
153 athena_opts=options.athena_opts,
154 conditions_tag = options.conditions_tag,
155 full_log = options.full_log,
158 except Exception
as err:
159 msg.error(
'problem while running sg-dump:\n%s', err)
161 traceback.print_exc()