-
Notifications
You must be signed in to change notification settings - Fork 9
/
collect_assignees.py
executable file
·48 lines (33 loc) · 1.17 KB
/
collect_assignees.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from pymongo import MongoClient
import os
from launchpad_reporting.db import db
from launchpad_reporting.launchpad.lpdata import LaunchpadAnonymousData
lpdata = LaunchpadAnonymousData(bugs_db=db)
connection = MongoClient()
db = connection["assignees"]
assignees = db.assignees
path_to_data = "/".join(os.path.abspath(__file__).split('/')[:-1])
with open('{0}/fuel_teams.json'.format(path_to_data)) as data_file:
data = json.load(data_file)
teams = ["Fuel", "Partners", "mos-linux", "mos-openstack"]
db.drop_collection(assignees)
global_team_list = {}
for team in teams:
people = []
people.extend(data[team]["teams"])
team_list = {}
for t in data[team]["teams"]:
team_list[t] = []
tt = lpdata.launchpad.people[t]
members = tt.members_details
for member in members:
people.append(member.member.name)
team_list[t].append(member.member.name)
global_team_list[team] = team_list
assignees.insert({"Team": "{0}".format(team),
"Members": people})
with open("file.json", "w") as f:
f.write(json.dumps(global_team_list))