344.1.1
by Steve Langasek
Move all shebangs to python3. |
1 |
#!/usr/bin/python3
|
30
by Ubuntu Archive
Add process-component-mismatches-diff |
2 |
# (C) 2011 Canonical Ltd.
|
3 |
# Author: Martin Pitt <martin.pitt@canonical.com>
|
|
4 |
# License: GPL-2+
|
|
5 |
#
|
|
6 |
# Process two reports of component-mismatches, and email new source
|
|
7 |
# universe->main promotions to the release team.
|
|
8 |
||
9 |
#from launchpadlib.launchpad import Launchpad
|
|
10 |
import difflib |
|
11 |
import sys |
|
12 |
import smtplib |
|
13 |
from email.mime.text import MIMEText |
|
14 |
||
15 |
||
16 |
def release_team_emails(): |
|
17 |
'''Return a list of email addresses of the release team.'''
|
|
18 |
||
19 |
# this only works authenticated:
|
|
20 |
#lp = Launchpad.login_anonymously('process-component-mismatches-diff', 'production')
|
|
21 |
#addresses = []
|
|
22 |
#for member in lp.people['ubuntu-release'].members_details:
|
|
23 |
# addresses.append(member.member.preferred_email_address_link.split('/')[-1])
|
|
24 |
#return addresses
|
|
25 |
return ['martin.pitt@ubuntu.com', |
|
26 |
'cjwatson@canonical.com', |
|
27 |
'iain@orangesquash.org.uk', |
|
28 |
'ubuntu@kitterman.com', |
|
29 |
'steve.langasek@canonical.com', |
|
30 |
'stefan.potyra@informatik.uni-erlangen.de'] |
|
31 |
||
32 |
def read_file(filename): |
|
33 |
'''Read the output of component-mismatches.
|
|
34 |
||
35 |
Filter out the "source/binary promotion to main" part, as this is the only
|
|
36 |
part for which timely email notifications are helpful and appropriate.
|
|
37 |
|
|
38 |
Return a list of lines.
|
|
39 |
'''
|
|
40 |
f = open(filename) |
|
41 |
result = [] |
|
42 |
||
43 |
# first, read until the first section starts
|
|
44 |
line = '' |
|
45 |
while '----------' not in line: |
|
46 |
line = f.readline() |
|
42
by Ubuntu Archive
process-component-mismatches-diff: don't spin when presented with an empty file |
47 |
if line == '': |
48 |
return result |
|
30
by Ubuntu Archive
Add process-component-mismatches-diff |
49 |
|
50 |
# slurp in the section
|
|
51 |
while True: |
|
52 |
line = f.readline() |
|
42
by Ubuntu Archive
process-component-mismatches-diff: don't spin when presented with an empty file |
53 |
if line == '' or line.startswith('========='): |
30
by Ubuntu Archive
Add process-component-mismatches-diff |
54 |
break
|
55 |
result.append(line) |
|
56 |
||
57 |
f.close() |
|
58 |
return result |
|
59 |
||
60 |
def report(old_cm, new_cm): |
|
61 |
'''Generate a report for the difference between two c-m results.'''
|
|
62 |
||
63 |
old = read_file(old_cm) |
|
64 |
new = read_file(new_cm) |
|
65 |
||
66 |
report = '' |
|
67 |
for i in difflib.Differ().compare(old, new): |
|
68 |
if i.startswith('+'): |
|
69 |
report += i[1:] |
|
70 |
return report |
|
71 |
||
72 |
#
|
|
73 |
# main
|
|
74 |
#
|
|
75 |
||
76 |
if len(sys.argv) != 3: |
|
77 |
sys.stderr.write('Usage: %s <old report> <new report>\n' % sys.argv[0]) |
|
78 |
sys.exit(0) |
|
79 |
||
80 |
r = report(sys.argv[1], sys.argv[2]) |
|
81 |
if not r: |
|
82 |
sys.exit() |
|
83 |
||
84 |
r = '''The following universe packages have new reverse dependencies |
|
85 |
in main or got seeded. They need to get a MainInclusionReport and be
|
|
86 |
promoted, or the reverse dependencies in main need to be dropped:
|
|
87 |
||
88 |
%s
|
|
349
by Steve Langasek
ubuntu-archive-team is https-only |
89 |
Please see https://ubuntu-archive-team.ubuntu.com/component-mismatches.txt
|
30
by Ubuntu Archive
Add process-component-mismatches-diff |
90 |
for the full report.
|
91 |
||
52
by Ubuntu Archive
change contact address to role account |
92 |
Please contact https://launchpad.net/~ubuntu-archive for problems with this
|
30
by Ubuntu Archive
Add process-component-mismatches-diff |
93 |
notification.
|
94 |
''' % r |
|
95 |
||
96 |
# send mail
|
|
97 |
#addrs = release_team_emails()
|
|
98 |
addrs = ['ubuntu-release@lists.ubuntu.com'] |
|
99 |
msg = MIMEText(r) |
|
100 |
msg['Subject'] = 'New component-mismatches for source universe -> main' |
|
305.1.1
by Sebastien Bacher
Use the team address for report emails |
101 |
msg['From'] = 'process-component-mismatches-diff <ubuntu-release@lists.ubuntu.com>' |
30
by Ubuntu Archive
Add process-component-mismatches-diff |
102 |
msg['To'] = ', '.join(addrs) |
103 |
msgstr = msg.as_string() |
|
104 |
||
105 |
for addr in addrs: |
|
106 |
s = smtplib.SMTP() |
|
107 |
s.connect() |
|
269.2.1
by Dimitri John Ledkov
No more emails from pitti |
108 |
s.sendmail('archive@ubuntu.com', addr, msgstr) |
30
by Ubuntu Archive
Add process-component-mismatches-diff |
109 |
s.quit() |