Merge lp://staging/~gary/launchpad/utf8-list-team-members into lp://staging/launchpad

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: not available
Merged at revision: not available
Proposed branch: lp://staging/~gary/launchpad/utf8-list-team-members
Merge into: lp://staging/launchpad
Diff against target: 24 lines (+5/-4)
1 file modified
scripts/list-team-members (+5/-4)
To merge this branch: bzr merge lp://staging/~gary/launchpad/utf8-list-team-members
Reviewer Review Type Date Requested Status
Māris Fogels (community) Approve
Review via email: mp+15768@code.staging.launchpad.net

Commit message

Make list-team-members support unicode, per a bug in production.

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

This cherrypick candidate came about because Tom informed me that a script (https://pastebin.canonical.com/25425/) which was calling list-team-members was generating this error:

Traceback (most recent call last):
 File "./list-team-members", line 60, in <module>
   script.run()
 File "/srv/launchpad.net/production/launchpad-rev-8745/lib/lp/services/scripts/base.py", line 248, in run
   self.main()
 File "./list-team-members", line 55, in main
   print "\n".join(sorted(list(set(member_details))))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 14282-14288: ordinal not in range(128)

This indicates that some of those details are unicode, and Python is trying to encode them in ascii, and failing. The changes in this branch addressed the problem by encoding the values in UTF8, and Tom indicated that this change would not be a problem.

Revision history for this message
Māris Fogels (mars) wrote :

Looks good to me, r=mars Feel free to clean up the nested list and set though ;)

print '\n'.join(detail.encode('utf-8') for detail in sorted(set(member_details)))

Maris

review: Approve
Revision history for this message
Gary Poster (gary) wrote :

Changed, per our further discussion on IRC. Thank you.

I should have mentioned at the start that the original change has been cowboyed for production.

Gary

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/list-team-members'
2--- scripts/list-team-members 2009-10-13 14:38:07 +0000
3+++ scripts/list-team-members 2009-12-07 19:44:19 +0000
4@@ -44,15 +44,16 @@
5 if not teamnames:
6 self.parser.error('No team specified')
7
8- member_details = []
9+ # We don't want duplicates, so use a set to enforce uniqueness.
10+ member_details = set()
11 for teamname in teamnames:
12 try:
13- member_details.extend(process_team(teamname, display_option))
14+ member_details.update(process_team(teamname, display_option))
15 except NoSuchTeamError:
16 print "Error, no such team: %s" % teamname
17 return 1
18- # We don't want duplicates, so use "set" get unique only
19- print "\n".join(sorted(list(set(member_details))))
20+ print "\n".join(detail.encode('utf-8') for detail in
21+ sorted(member_details))
22 return 0
23
24 if __name__ == '__main__':