CMS 3D CMS Logo

dataset.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import os
4 import pprint
5 import fnmatch
6 from PhysicsTools.HeppyCore.utils.dataset import createDataset
7 
8 if __name__ == '__main__':
9 
10  import sys
11  from optparse import OptionParser
12  import pprint
13 
14  parser = OptionParser()
15  parser.usage = "%prog [options] <dataset>\nPrints information on a sample."
16  parser.add_option("-w", "--wildcard", dest="wildcard", default='tree*root',help='A UNIX style wilfcard for root file printout')
17  parser.add_option("-u", "--user", dest="user", default=os.environ.get('USER', None),help='user owning the dataset.\nInstead of the username, give "LOCAL" to read datasets in a standard unix filesystem, and "CMS" to read official CMS datasets present at CERN.')
18  parser.add_option("-b", "--basedir", dest="basedir", default=os.environ.get('CMGLOCALBASEDIR',None),help='in case -u LOCAL is specified, this option allows to specify the local base directory containing the dataset. default is CMGLOCALBASEDIR')
19  parser.add_option("-a", "--abspath", dest="abspath",
20  action = 'store_true',
21  default=False,
22  help='print absolute path')
23  parser.add_option("-n", "--noinfo", dest="noinfo",
24  action = 'store_true',
25  default=False,
26  help='do not print additional info (file size and status)')
27  parser.add_option("-r", "--report", dest="report",
28  action = 'store_true',
29  default=False,
30  help='Print edmIntegrityCheck report')
31  parser.add_option("-c", "--readcache", dest="readcache",
32  action = 'store_true',
33  default=False,
34  help='Read from the cache.')
35  parser.add_option("--min-run", dest="min_run", default=-1, type=int, help='When querying DBS, require runs >= than this run')
36  parser.add_option("--max-run", dest="max_run", default=-1, type=int, help='When querying DBS, require runs <= than this run')
37 
38  (options,args) = parser.parse_args()
39 
40  if len(args)!=1:
41  parser.print_help()
42  sys.exit(1)
43 
44  user = options.user
45  name = args[0]
46  info = not options.noinfo
47 
48  run_range = (options.min_run,options.max_run)
49  data = createDataset(user, name,
50  fnmatch.translate( options.wildcard ),
51  options.readcache,
52  options.basedir,
53  run_range=run_range)
54  data.printInfo()
55  data.printFiles(abspath = options.abspath,
56  info = info)
57  pprint.pprint( data.filesAndSizes )
58  if options.report:
59  pprint.pprint( data.report )
60 
61 
def createDataset(user, dataset, pattern, readcache=False, basedir=None, run_range=None)
Definition: dataset.py:430