diff --git a/Script/MergedMigratedNew.py b/Script/MergedMigratedNew.py deleted file mode 100644 index 3c145bb77b69ca733249a14d043b6cb05c5cb547..0000000000000000000000000000000000000000 --- a/Script/MergedMigratedNew.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/env python - -__version__='$Revision$' -# $Source$ - -from SFOFileNameParser import SFOFileNameParser -import os.path -import sys -from subprocess import * - -BASEDIR = '/castor/cern.ch/grid/atlas/tzero/prod1/perm/' - -def nsls(target, castorenv, opts=[]): - - command = ['nsls'] - command.extend(opts) - command.append(target) - - kwds = {} - - if castorenv: - kwds['env'] = castorenv - - nsls = Popen(command, stdout = PIPE, - stderr = STDOUT, **kwds) - - nslsOut, _ = nsls.communicate() - ret = nsls.wait() - - return ((ret == 0), nslsOut) - - -def MergedMigratedNew(castorfile, castorenv, verbose = False): - """ -Destination directory: -/<basedir>/<projecttag>/<streamtype_streamname>/<runnr-7digit>/<dataset>/ - -basedir = /castor/cern.ch/grid/atlas/tzero/prod1/perm/ -projecttag = data09_cos -dataset = data09_cos.00122050.physics_IDCosmic.merge.RAW - -Merged file name is: - -1) if all SFO files of a LB fit into a single file - <project>.<runnr>.<stream>.daq.RAW._lbXXXX._SFO-N._<fileseqnr>.data, N=4,5,9,10 - --> <project>.<runnr>.<stream>.merge.RAW._lbXXXX._SFO-ALL._0001.<attemptnr> - -2) if all SFO files of a LB don't fit into a single file - <project>.<runnr>.<stream>.daq.RAW._lbXXXX._SFO-N._<fileseqnr>.data, N=4,5,9,10 - --> <project>.<runnr>.<stream>.merge.RAW._lbXXXX._SFO-N._<fileseqnr>.<attemptnr>, N=4,5,9,10 - """ - ### Build the target directory name - parsed = SFOFileNameParser(os.path.basename(castorfile)) - - dataset = '%s.%s.%s_%s.merge.RAW' \ - % (parsed.ProjectTag(), parsed.RunNr(), \ - parsed.StreamType(), parsed.StreamName()) - - - path = os.path.join(BASEDIR, parsed.ProjectTag(), \ - '%s_%s' % (parsed.StreamType(), parsed.StreamName()), \ - '%s' % parsed.RunNr(), \ - '%s' % dataset) - if verbose: - print path - - ### Look for files into the dataset dir - success, all_files = nsls(path, castorenv) - - ### If fails, return false - if not success: return False - - ### Create the two type of name we expect (neglecting attempt number) - notmerged = os.path.splitext(os.path.basename(castorfile))[0] - notmerged = notmerged.replace('.daq.','.merge.') - merged = '.'.join(notmerged.split('.',6)[:-1]+['_SFO-ALL._0001']) - - ### Find all the files with the correct name - files = [f for f in all_files.split('\n') - if f and (notmerged in f or merged in f)] - - if not files: return False - - ### Take the file with the highest attempt number - file = sorted([(int(f.rsplit('.',1)[1]),f) for f in files])[-1][1] - - ### Check the migration status for the file - success, out = nsls(os.path.join(path, file), \ - castorenv, opts = ['-l']) - - if success and 'm' in out.split(' ')[0]: return True - else: return False - -if __name__ == '__main__': - - print MergedMigratedNew(sys.argv[1], '', verbose=True) - - - - - -