Merge lp:~cjohnston/launchpad/900216 into lp:launchpad

Proposed by Chris Johnston
Status: Merged
Merged at revision: 17152
Proposed branch: lp:~cjohnston/launchpad/900216
Merge into: lp:launchpad
Diff against target: 55 lines (+33/-1)
2 files modified
lib/lp/archiveuploader/tests/test_ppauploadprocessor.py (+32/-0)
lib/lp/archiveuploader/uploadprocessor.py (+1/-1)
To merge this branch: bzr merge lp:~cjohnston/launchpad/900216
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+229659@code.launchpad.net

Commit message

Support unicode in PPAUploadPathError's

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

That's a bit of a hack. We only ever raise an UploadPathError with a single argument that's either an ASCII str or a unicode, so I'd just use e.args[0] in place of str(e).

review: Needs Fixing (code)
Revision history for this message
Chris Johnston (cjohnston) wrote :

Updated

Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py'
2--- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2014-07-09 06:34:14 +0000
3+++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2014-08-06 13:21:32 +0000
4@@ -1011,6 +1011,38 @@
5 "File bar_1.0.orig.tar.gz already exists in unicode PPA name: "
6 "áří" in body)
7
8+ def testErrorMessagesWithArchiveDisplayNameUnicodeArchiveDisabled(self):
9+ """Check that unicode errors messages are handled correctly.
10+
11+ Some error messages can contain the PPA display name, which may
12+ sometimes contain unicode characters. We need to show proper errors
13+ when a disabled PPA with a unicode display name gets an upload.
14+ """
15+ # Ensure the displayname of the PPA has got unicode in it.
16+ self.name16.archive.displayname = u"unicode PPA name: áří"
17+ self.name16.archive.disable()
18+ # Upload to disabled archive.
19+ upload_dir = self.queueUpload("bar_1.0-1", "~name16/ubuntu")
20+ self.processUpload(self.uploadprocessor, upload_dir)
21+
22+ # The email generated should be sane.
23+ from_addr, to_addrs, raw_msg = stub.test_emails.pop()
24+ msg = message_from_string(raw_msg)
25+ body = msg.get_payload(0)
26+ body = body.get_payload(decode=True)
27+
28+ self.assertTrue(
29+ "Rejected:\n"
30+ "Launchpad failed to process the upload path '~name16/ubuntu':\n\n"
31+ "unicode PPA name: áří is disabled.\n\n"
32+ "It is likely that you have a configuration problem with "
33+ "dput/dupload.\n"
34+ "Please check the documentation at "
35+ "https://help.launchpad.net/Packaging/PPA#Uploading and update "
36+ "your configuration.\n\n"
37+ "Further error processing not possible because of a critical "
38+ "previous error." in body)
39+
40 def testPPAConflictingOrigFiles(self):
41 """When available, the official 'orig.tar.gz' restricts PPA uploads.
42
43
44=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
45--- lib/lp/archiveuploader/uploadprocessor.py 2014-07-07 02:46:56 +0000
46+++ lib/lp/archiveuploader/uploadprocessor.py 2014-08-06 13:21:32 +0000
47@@ -351,7 +351,7 @@
48 # will break nascentupload ACL calculations.
49 archive = distribution.getAllPPAs()[0]
50 upload_path_error = UPLOAD_PATH_ERROR_TEMPLATE % (
51- dict(upload_path=relative_path, path_error=str(e),
52+ dict(upload_path=relative_path, path_error=e.args[0],
53 extra_info=(
54 "Please check the documentation at "
55 "https://help.launchpad.net/Packaging/PPA#Uploading "