Exemplo n.º 1
0
"""

	parser = OptionParser(usage=usage)
	parser.add_option("-t", dest="treeproducername", type='string', default="myTreeProducer", help='Name of the tree producer module')
	parser.add_option("-f", dest="friendtreestring", type='string', default="evVarFriend", help='String identifying friend trees (must be contained in the root file name)')
	parser.add_option("-T", dest="treename", type='string', default="tree.root", help='Name of the tree file')
	parser.add_option("--dset", dest="dset", type='string', default=None, help='Name of the dataset to process')
	(options, args) = parser.parse_args()
	if len(args)<2: raise RuntimeError, 'Expecting at least two arguments'
	
	locdir = args[0]
	remdir = args[1]
	
	
	if not eostools.isEOS(remdir): raise RuntimeError, 'Remote directory should be on EOS.'
	if (not eostools.fileExists(locdir)) or eostools.isFile(locdir): 
	    raise RuntimeError, 'The local directory that should contain the trees does not exist.'

# check removed to allow for top-up of tree productions
#	if eostools.fileExists('%s/%s' % (remdir,locdir)):
#	    raise RuntimeError, 'The remote EOS directory where the trees should be archived already exists.'
	
	alldsets = eostools.ls(locdir)
	dsets = [d for d in alldsets if [ fname for fname in eostools.ls(d) if options.friendtreestring in fname]==[] ]
	if options.dset: dsets = [d for d in dsets if options.dset in d]
	friends = [d for d in alldsets if d not in dsets]
	if options.dset: friends = [d for d in friends if options.dset in d]
	
	tocopy = []
	for d in dsets:
Exemplo n.º 2
0
    parser.add_option(
        "-F",
        "--force",
        dest="force",
        action="store_true",
        default=False,
        help=
        "Skip files or directories that don't contain trees, without raising an error"
    )
    (options, args) = parser.parse_args()
    if len(args) < 2: raise RuntimeError, 'Expecting at least two arguments'

    locdir = args[0]
    remdir = os.path.join(args[1], os.path.basename(locdir))

    if not eostools.isEOS(remdir):
        raise RuntimeError, 'Remote directory should be on EOS.'
    if (not eostools.fileExists(locdir)) or eostools.isFile(locdir):
        raise RuntimeError, 'The local directory that should contain the trees does not exist.'

# check removed to allow for top-up of tree productions
#	if eostools.fileExists('%s/%s' % (remdir,locdir)):
#	    raise RuntimeError, 'The remote EOS directory where the trees should be archived already exists.'

    alldsets = [p for p in glob.glob(locdir + "/*") if os.path.isdir(p)]
    if not options.allowSymlinks:
        symlinks = [d for d in alldsets if os.path.islink(d)]
        if symlinks:
            print "The following directories are symlinks and will not be considered (run with --allowSymlinks to include them): ", ", ".join(
                map(os.path.basename, symlinks))
            alldsets = [d for d in alldsets if not os.path.islink(d)]
Exemplo n.º 3
0
    parser.add_option("--dryrun",
                      dest="dryrun",
                      action="store_true",
                      default=False,
                      help='only print the commands, do not run the copy')
    (options, args) = parser.parse_args()

    if len(args) < 2: raise RuntimeError, 'Expecting at least two arguments'

    eosdir = args[0]
    remdir = args[1]

    listfiles = []
    if len(args) == 3: listfiles = open(args[2]).readlines()

    if not eostools.isEOS(eosdir):
        raise RuntimeError, 'Remote directory should be on EOS.'

    if len(listfiles) > 0: files = listfiles
    else: files = eostools.ls(eosdir)
    if options.select: files = [f for f in files if options.select in f]
    if options.remove: files = [f for f in files if options.remove not in f]

    tocopy = []
    for f in files:
        basename = os.path.basename(f)
        tocopy.append(basename)
        print "Will copy file ", basename

    print '\nCopy the above files from %s -> %s. Do you agree? [y/N]\n' % (
        eosdir, remdir)