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