forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listProtectedLFN.py
executable file
·40 lines (33 loc) · 1.1 KB
/
listProtectedLFN.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
import itertools
import httplib
import os
import json
import time
from collections import defaultdict
from utils import monitor_pub_dir, workflowInfo, getWorkflows
register=[
#'assigned','acquired',
'running-open','running-closed','force-complete','completed','closed-out']
wfs = []
url = 'cmsweb.cern.ch'
for r in register:
wfs.extend( getWorkflows(url, r ,details=True) )
print len(wfs),"after collecting",r
lfns =defaultdict(set)
for wf in wfs:
if 'OutputModulesLFNBases' not in wf:
print wf['RequestName']
for base in wf['OutputModulesLFNBases']:
lfns[base].add( wf['RequestName'] )
now = time.gmtime()
content = { "timestamp" : time.mktime(now),
"date" : time.asctime(now),
"protected" : sorted(lfns.keys())
}
open('%s/listProtectedLFN.txt'%monitor_pub_dir,'w').write( json.dumps( content, indent=2))
#open('%s/listProtectedLFN.txt.2'%monitor_pub_dir,'w').write( json.dumps( content, indent=2))
#print '\n'.join( sorted(lfns.keys()) )
for lfn in lfns:
print lfn
for wf in lfns[lfn]:
print "\t protected by ",wf