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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#! /usr/bin/python
#
# Copyright (C) 2009 Canonical Ltd
"""Check copyright agreement has been signed for proposals.
usage: scan-merge-proposals PROJECT_ID
People are considered OK if they're in either of two groups:
* <https://launchpad.net/~contributor-agreement-canonical>
meaning they've signed <http://www.canonical.com/contributors>, or
* <https://launchpad.net/~canonical> meaning they've signed
an employment agreement.
Some caveats:
* the contributor agreement team is not definitive; there
may be people who've signed who are not in this team (but
they should be added)
* this script will only work when run by members of ~canonical,
because it's a private team
"""
import sys
import hydrazine
# XXX: what to do if the registrant is a team like ~bzr?
#
# XXX: what to do if this script is run by somebody not authorized to know if
# a person is a member of ~canonical?
AUTHORIZED_TEAMS = [
'contributor-agreement-canonical',
'canonical']
def main(argv):
if len(argv) != 2:
print __doc__
return 3
launchpad = hydrazine.create_session()
project = launchpad.projects[argv[1]]
# map from person name to a team they're in
ok_people = {}
needs_to_sign = {} # name->person
for team_name in AUTHORIZED_TEAMS:
team = launchpad.people[team_name]
for person in team.members:
ok_people[person.name] = team_name
for mp in project.getMergeProposals():
if mp.queue_status not in ['Needs review',
'Approved',]:
continue
print hydrazine.web_url(mp.self_link)
# registrant is the registrant of the proposed-to-merge branch, ie
# pretty much the owner of that branch
registrant_name = mp.registrant.name
if registrant_name in needs_to_sign:
print ' %s already needs to sign' % registrant_name
elif registrant_name not in ok_people:
print '**** %s not signed up' % registrant_name
needs_to_sign[registrant_name] = mp.registrant
else:
print '<<<< yay, a member of %s' % ok_people[mp.registrant.name]
print ' status %s' % mp.queue_status
print
if needs_to_sign:
print
print 'The following people need to sign the contributor agreement'
for person_name, person in sorted(needs_to_sign.items()):
real_url = hydrazine.web_url(person.self_link)
print '%s <%s>' % (person.display_name, real_url)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
|