forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathds2block.py
executable file
·34 lines (31 loc) · 941 Bytes
/
ds2block.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
#!/usr/bin/env python
from sys import argv, stdin
from CMSWeb import CMSWeb
cms=CMSWeb()
detail = False
cern = False
for arg in argv:
if arg=="--detail": detail=True
elif arg=="--all": cern=True
for dataset in stdin:
dataset = dataset.strip("\n")
if not dataset: continue
blocks = cms.search_blocks(dataset)
min_bsize=999999999999999999999999999999
bselected = []
at_cern = False
all_blocks = {}
for block in blocks:
bname = block['block_name']
if cms.search_block(bname):
bsize = cms.cache['blocks_raw'][bname]['phedex']['block'][0] ['bytes']/(1024*1024)
all_blocks[bname]=[cms.cache["replicas"][bname].keys() , bsize]
if cms.cache['blocks'][bname]['at_cern']=='yes':
at_cern = True
bselected = bname
if bsize<min_bsize:
min_bsize = bsize
bselected = bname
if not cern and at_cern: continue
if detail: print all_blocks
else: print bselected