Newer
Older
STAging / scripts / ganga / STRetrieveOutputs.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Elena Graverini
# @Date:   2015-07-08 09:35:46
# @Last Modified by:   Elena Graverini
# @Last Modified time: 2015-12-14 15:18:24
import pickle

lfns = {}
eospaths = {}
#sel_jobs = [jobs(6), jobs(7), jobs(9), jobs(10), jobs(11), jobs(13)]
sel_jobs = [jobs(14), jobs(15), jobs(16)]

for j in sel_jobs:
    eospaths[j.id] = []
    lfns[j.id] = []
    for sj in j.subjobs:
        if sj.status == 'completed' or sj.status == 'completing':
            outfiles = sj.outputfiles
            tuple = [f for f in outfiles if f.namePattern == 'Tuple.root'][0]
            lfn = tuple.lfn
            lfns[j.id].append(lfn)
            if 'CERN-USER' in tuple.locations:
                replica = LogicalFile(lfn).getReplicas()['CERN-USER']
                eospath = replica.replace('srm://srm-', 'root://')
                eospaths[j.id].append(eospath)
                print j.id, sj.id, type(lfn), lfn
                print j.id, sj.id, type(eospath), eospath
            else:
                print '\tWARNING: no CERN replica for subjob %s.%s' % (j.id, sj.id)
                print 'Replica found at %s' % tuple.locations

outputs = {'lfns': lfns, 'eospaths': eospaths}
#pickle.dump(outputs, open('Nov2015.pkl', 'wb'))
pickle.dump(outputs, open('Nov2015-IT.pkl', 'wb'))