print 'Will create EOS directory %s and copy the following files:\n'%newdir
	for task in tocopy: print '%s -> %s' % task
	
	print '\nDo you agree? [y/N]\n'
	if raw_input()!='y':
	    print 'Aborting'
	    exit()
	
	eostools.mkdir(newdir)
	if not eostools.fileExists(newdir): raise RuntimeError, 'Impossible to create remote directory.'
	for task in tocopy:
	    eostools.xrdcp(task[0],task[1])
	    fcmd = open(task[0]+".url","w")
	    fcmd.write("root://eoscms.cern.ch/%s\n" % task[1])
	    fcmd.close()
	print 'Copied %.2f GB to EOS\n' % eostools.eosDirSize(newdir)

	print 'Verifying checksums:\n'
	problem = False
	for task in tocopy:
		lcheck = eostools.fileChecksum(task[0])
		rcheck = eostools.fileChecksum(task[1])
		ok = (lcheck==rcheck)
		print task[0],lcheck,rcheck,('OK' if ok else 'ERROR')
		if not ok: problem = True
	if problem:
		raise RuntimeError, 'CHECKSUM ERROR DETECTED !!!'
	else:
		print '\nALL CHECKSUMS OK\n'
		print '\nIf you want, you can rename the local root files to force usage of the remote EOS copy for testing:\n'
		for task in tocopy: print 'mv -n %s %s.transferred'%(task[0],task[0])
        print '%s -> %s' % task

    print '\nDo you agree? [y/N]\n'
    if raw_input() != 'y':
        print 'Aborting'
        exit()

    eostools.mkdir(remdir)
    if not eostools.fileExists(remdir):
        raise RuntimeError, 'Impossible to create remote directory.'
    for task in tocopy:
        eostools.xrdcp(task[0], task[1])
        fcmd = open(task[0] + ".url", "w")
        fcmd.write("root://eoscms.cern.ch/%s\n" % task[1])
        fcmd.close()
    print 'Copied %.2f GB to EOS\n' % eostools.eosDirSize(remdir)

    print 'Verifying checksums:\n'
    problem = False
    for task in tocopy:
        lcheck = eostools.fileChecksum(task[0])
        rcheck = eostools.fileChecksum(task[1])
        ok = (lcheck == rcheck)
        print task[0], lcheck, rcheck, ('OK' if ok else 'ERROR')
        if not ok: problem = True
    if problem:
        raise RuntimeError, 'CHECKSUM ERROR DETECTED !!!'
    else:
        print '\nALL CHECKSUMS OK\n'
        print '\nIf you want, you can rename the local root files to force usage of the remote EOS copy for testing:\n'
        for task in tocopy:
示例#3
0
#!/bin/env python

import sys
import CMGTools.Production.eostools as eostools

print eostools.eosDirSize( sys.argv[1] )