Merge lp:~brian-murray/ubuntu-archive-tools/phased-updater-codecs into lp:ubuntu-archive-tools

Proposed by Brian Murray
Status: Merged
Merged at revision: 1029
Proposed branch: lp:~brian-murray/ubuntu-archive-tools/phased-updater-codecs
Merge into: lp:ubuntu-archive-tools
Diff against target: 63 lines (+12/-11)
1 file modified
phased-updater (+12/-11)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-archive-tools/phased-updater-codecs
Reviewer Review Type Date Requested Status
Steve Langasek Needs Information
Barry Warsaw Pending
Review via email: mp+296855@code.launchpad.net

Description of the change

Use codecs.open() to write the NOTIFICATIONS file so that we can handle packages changed by people with unicode in their names. Additionally, stop reading the NOTIFICATIONS file with csv.reader since it doesn't handle unicode easily. I also fixed an inconsistency with writing signer.name instead of signer_name to the NOTIFICATIONS file for an increased rate.

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

LGTM with just a few questions, but nothing that blocks landing.

Revision history for this message
Steve Langasek (vorlon) wrote :

See inline comments.

review: Needs Information
1029. By Brian Murray

address reviewer feedback

Revision history for this message
Brian Murray (brian-murray) wrote :

Thanks for the feedback, I've made the suggested changes!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phased-updater'
2--- phased-updater 2016-06-07 16:03:17 +0000
3+++ phased-updater 2016-06-08 22:16:55 +0000
4@@ -27,6 +27,7 @@
5 from __future__ import print_function
6
7 import apt
8+import codecs
9 import csv
10 import datetime
11 import logging
12@@ -206,14 +207,14 @@
13 from email.mime.text import MIMEText
14 notifications = defaultdict(list)
15 try:
16- with open(NOTIFICATIONS, 'r') as notify_file:
17- notify_csv = csv.reader(notify_file)
18- for row in notify_csv:
19+ with codecs.open(NOTIFICATIONS, 'r', encoding='utf-8') as notify_file:
20+ for line in notify_file.readlines():
21+ line = line.strip('\n').split(', ')
22 # LP name, problem, pkg_version
23- person = row[0].strip()
24- problem = row[1].strip()
25- pkg = row[2].strip()
26- pkg_version = row[3].strip()
27+ person = line[0]
28+ problem = line[1]
29+ pkg = line[2]
30+ pkg_version = line[3]
31 notifications[person].append((problem, pkg, pkg_version))
32 except IOError:
33 pass
34@@ -267,7 +268,7 @@
35 for line in changes_file.readlines():
36 line = line.strip()
37 if line.startswith('Changed-By:'):
38- changer = line.lstrip('Changed-By: ')
39+ changer = line.lstrip('Changed-By: ').decode('utf-8')
40 signer_name, signer_email = utils.parseaddr(changer.strip())
41 break
42 logging.info("Used changes file to find email for %s %s %s" %
43@@ -315,7 +316,7 @@
44 smtp.quit()
45 logging.info('%s mailed about %s' % (receivers, subject))
46 # add signer, problem, pkg, version to notifications csv file
47- with open(NOTIFICATIONS, 'a') as notify_file:
48+ with codecs.open(NOTIFICATIONS, 'a', encoding='utf-8') as notify_file:
49 for bucket in spph_buckets[rname][spph]['buckets']:
50 notify_file.write('%s, %s, %s, %s\n' % \
51 (signer_name, bucket,
52@@ -350,9 +351,9 @@
53 logging.info('%s mailed about %s' % (receivers, subject))
54 # add signer, increased-rate, pkg, version to
55 # notifications csv
56- with open(NOTIFICATIONS, 'a') as notify_file:
57+ with codecs.open(NOTIFICATIONS, 'a', encoding='utf-8') as notify_file:
58 notify_file.write('%s, increased-rate, %s, %s\n' %
59- (signer.name, pkg, version))
60+ (signer_name, pkg, version))
61
62
63 def new_buckets(archive, release, src_pkg, version):

Subscribers

People subscribed via source and target branches