Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:30

0001 #!/usr/bin/env python3
0002 
0003 import os
0004 import pprint
0005 import fnmatch
0006 from PhysicsTools.HeppyCore.utils.dataset import createDataset
0007 
0008 if __name__ == '__main__':
0009 
0010     import sys
0011     from optparse import OptionParser
0012     import pprint
0013     
0014     parser = OptionParser()
0015     parser.usage = "%prog [options] <dataset>\nPrints information on a sample."
0016     parser.add_option("-w", "--wildcard", dest="wildcard", default='tree*root',help='A UNIX style wilfcard for root file printout')
0017     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.')
0018     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')
0019     parser.add_option("-a", "--abspath", dest="abspath",
0020                       action = 'store_true',
0021                       default=False,
0022                       help='print absolute path')
0023     parser.add_option("-n", "--noinfo", dest="noinfo",
0024                       action = 'store_true',
0025                       default=False,
0026                       help='do not print additional info (file size and status)')
0027     parser.add_option("-r", "--report", dest="report",
0028                       action = 'store_true',
0029                       default=False,
0030                       help='Print edmIntegrityCheck report')
0031     parser.add_option("-c", "--readcache", dest="readcache",
0032                       action = 'store_true',
0033                       default=False,
0034                       help='Read from the cache.')
0035     parser.add_option("--min-run", dest="min_run", default=-1, type=int, help='When querying DBS, require runs >= than this run')
0036     parser.add_option("--max-run", dest="max_run", default=-1, type=int, help='When querying DBS, require runs <= than this run')
0037 
0038     (options,args) = parser.parse_args()
0039 
0040     if len(args)!=1:
0041         parser.print_help()
0042         sys.exit(1)
0043 
0044     user = options.user
0045     name = args[0]
0046     info = not options.noinfo
0047 
0048     run_range = (options.min_run,options.max_run)
0049     data = createDataset(user, name,
0050                          fnmatch.translate( options.wildcard ),
0051                          options.readcache,
0052                          options.basedir,
0053                          run_range=run_range)
0054     data.printInfo()
0055     data.printFiles(abspath = options.abspath,
0056                     info = info)
0057     pprint.pprint( data.filesAndSizes )
0058     if options.report:
0059         pprint.pprint( data.report )
0060 
0061