3 from __future__
import print_function
4 from PhysicsTools.HeppyCore.utils.edmIntegrityCheck
import PublishToFileSystem, IntegrityCheck
9 if __name__ ==
'__main__':
11 from optparse
import OptionParser, OptionGroup
13 usage =
"""usage: %prog [options] /Sample/Name/On/Castor
15 e.g.: %prog -u wreece -p -w 'PFAOD_*.root' /MultiJet/Run2011A-05Aug2011-v1/AOD/V2
18 group = OptionGroup(das.parser,
'edmIntegrityCheck Options',
'Options related to checking files on CASTOR')
20 group.add_option(
"-d",
"--device", dest=
"device", default=
'cmst3',help=
"The storage device to write to, e.g. 'cmst3'")
21 group.add_option(
"-n",
"--name", dest=
"name", default=
None,help=
'The name of the dataset in DAS. Will be guessed if not specified')
22 group.add_option(
"-p",
"--printout", dest=
"printout", default=
False, action=
'store_true',help=
'Print a report to stdout')
23 group.add_option(
"-r",
"--recursive", dest=
"resursive", default=
False, action=
'store_true',help=
'Walk the mass storage device recursively')
24 group.add_option(
"-u",
"--user", dest=
"user", default=os.environ[
'USER'],help=
'The username to use when looking at mass storage devices')
25 group.add_option(
"-w",
"--wildcard", dest=
"wildcard", default=
None,help=
'A UNIX style wildcard to specify which files to check')
26 group.add_option(
"--update", dest=
"update", default=
False, action=
'store_true',help=
'Only update the status of corrupted files')
27 group.add_option(
"-t",
"--timeout", dest=
"timeout", default=-1, type=int, help=
'Set a timeout on the edmFileUtil calls')
28 group.add_option(
"--min-run", dest=
"min_run", default=-1, type=int, help=
'When querying DBS, require runs >= than this run')
29 group.add_option(
"--max-run", dest=
"max_run", default=-1, type=int, help=
'When querying DBS, require runs <= than this run')
30 group.add_option(
"--max_threads", dest=
"max_threads", default=
None,help=
'The maximum number of threads to use')
31 das.parser.add_option_group(group)
32 (opts, datasets) = das.get_opt()
35 print(das.parser.print_help())
37 print(
'need to provide a dataset in argument')
50 previous = pub.get(check.directory)
52 check.test(previous = previous, timeout = op.timeout)
55 report = check.structured()
61 print(
'Checking thread done: ',
str(result))
65 if len(datasets) == 1:
67 work(d, copy.deepcopy(opts))
69 import multiprocessing
70 if opts.max_threads
is not None and opts.max_threads:
71 opts.max_threads = int(opts.max_threads)
72 pool = multiprocessing.Pool(processes=opts.max_threads)
75 pool.apply_async(work, args=(d,copy.deepcopy(opts)),callback=callback)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)