-
Notifications
You must be signed in to change notification settings - Fork 7
/
checkCrabStatus.py
67 lines (62 loc) · 2.89 KB
/
checkCrabStatus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os, commands
import argparse
from glob import glob
parser = argparse.ArgumentParser()
parser.add_argument ('inputDir', type=str, default='tmp/crab_*', help='Input dir template for glob', nargs='+')
parser.add_argument ('--report', default=False, action='store_true')
parser.add_argument ('--long', default=False, action='store_true')
parser.add_argument ('--short', default=False, action='store_true')
parser.add_argument ('--verboseErrors', default=False, action='store_true')
parser.add_argument ('--brilcalc', default=False, action='store_true')
args = parser.parse_args()
if args.brilcalc:
args.report = True
for dir in args.inputDir:
if os.path.isdir(dir):
print 20*'#' + 50*'-' + 20*'#'
cmd = 'source /cvmfs/cms.cern.ch/crab3/crab.sh; '
cmd += 'crab status -d ' + dir
if args.verboseErrors:
cmd += ' --verboseErrors'
if args.long:
cmd += ' --long'
if args.short:
stats, output = commands.getstatusoutput(cmd)
outLines = output.split('\n')
print outLines[0][outLines[0].find('tmp/crab_') + 9: ]
for i, l in enumerate(outLines):
if l.startswith('Jobs status:'):
jf = 1
while '%' in outLines[i+jf]:
jf += 1
print '\n'.join(outLines[i:i+jf])
break
else:
os.system(cmd)
if args.report:
print '\n' + 70*'~' + '\n'
cmd = 'source /cvmfs/cms.cern.ch/crab3/crab.sh; '
cmd += 'crab report -d ' + dir
os.system(cmd)
if args.brilcalc:
print 'Running brilcalc...\n'
cmd = 'export PATH=$HOME/.local/bin:/cvmfs/cms-bril.cern.ch/brilconda/bin:$PATH'
cmd += '; brilcalc lumi -u /fb'
if os.uname()[1] == 'login-1.hep.caltech.edu':
cmd += ' -c web'
cmd += ' --normtag /cvmfs/cms-bril.cern.ch/cms-lumi-pog/Normtags/normtag_PHYSICS.json'
cmd += ' -i ' + dir + '/results/processedLumis.json'
cmd += ' -o ' + dir + '/results/lumiReport_brilcalc.csv'
cmd += '; tail ' + dir + '/results/lumiReport_brilcalc.csv'
os.system(cmd)
cmd = 'cp ' + dir + '/results/lumiReport_brilcalc.csv'
if os.uname()[1] == 'login-1.hep.caltech.edu':
cmd += ' /storage/user/ocerri/BPhysics/data/cmsRD/lumiReport/'
else:
cmd += ' /afs/cern.ch/user/o/ocerri/cernbox/BPhysics/data/cmsRD/lumiReport/'
cmd += os.path.basename(dir)[5:] + '_bricalc.csv'
os.system(cmd)
if not args.short:
print 20*'#' + 50*'-' + 20*'#' + '\n\n'
if not args.short:
print 'For info on exit codes visit: https://twiki.cern.ch/twiki/bin/viewauth/CMSPublic/JobExitCodes'