forked from Mirantis/launchpad-reports-summary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollect_assignees.py
42 lines (30 loc) · 1.05 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import pymongo
import os
from launchpad_reporting.db import db
from launchpad_reporting.launchpad.lpdata import LaunchpadData
lpdata = LaunchpadData(db=db)
connection = pymongo.Connection()
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)
for team in teams:
people = []
people.extend(data[team]["teams"])
people.extend(data[team]["people"])
for t in data[team]["teams"]:
tt = lpdata.launchpad.people[t]
members = tt.members_details
for member in members:
people.append(member.member.name)
for member in data["excludes"]["people"]:
if member in people:
people.remove(member)
assignees.insert({"Team": "{0}".format(team),
"Members": people})