blob: 4a3d2284c93409fb489c72a4675e422bb778910c (
plain) (
blame)
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
|
#!/usr/bin/env python
import sys
from collections import defaultdict
def main():
input = sys.argv[1]
batch_number = sys.argv[2]
mms = {}
max_mmset_size = 0
with open(input, 'r') as f:
for l in f:
mm, hostname = l.rstrip().split(' ')
if mm not in mms:
mms[mm] = []
mms[mm].append(hostname)
max_mmset_size = max([len(mms[x]) for x in mms])
batches = {x: [] for x in range(0, max_mmset_size)}
for i in range(0, max_mmset_size):
for mm in mms:
if len(mms[mm]) -1 >= i:
batches[i].append(mms[mm][i])
for h in batches[int(batch_number)]:
print(h)
if __name__ == '__main__':
main()
|