Merge lp:~roadmr/checkbox/templates-utf8-encoding into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 1446
Proposed branch: lp:~roadmr/checkbox/templates-utf8-encoding
Merge into: lp:checkbox
Diff against target: 45 lines (+5/-3)
3 files modified
checkbox/lib/template.py (+1/-1)
debian/changelog (+3/-1)
plugins/message_info.py (+1/-1)
To merge this branch: bzr merge lp:~roadmr/checkbox/templates-utf8-encoding
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Review via email: mp+111087@code.launchpad.net

Description of the change

This fixes the linked bug by explicitly setting the encoding when opening a job/template file.

It would in theory be better to honor the system's encoding, however note that the encoding set in /etc/default/locale is not necessarily the same as that of files that are shipped with a package. Also, since the encoding for the C locale, which is what upstart jobs have, is bogus, assuming UTF-8 in all cases seems safe enough.

Just for kicks, I tried seeing if the system had an invalid encoding set, to fall back to UTF-8 only in that case. But none of the things I tried (locale.getpreferredencoding, sys.getdefaultencoding and sys.getfilesystemencoding) let us discern between an incorrectly set (or unset) encoding and a valid but funky one; i.e. if the user *actually* has LANG=en_US.ANSI_X3.4-1968. So just assuming UTF-8 seems to offer the least chances of us shooting ourselves in the foot by trying to be too clever.

I tested this on a server (where the problem was first observed) by applying these changes manually and then rebooting the server, and there were no errors in the logfile; all jobs were loaded correctly.

To post a comment you must log in.
1440. By Daniel Manrique

Merged from trunk

1441. By Daniel Manrique

Fix crappy changelog formatting

Revision history for this message
Marc Tardif (cr3) wrote :

Looks perfectly reasonable, thanks for testing this extensively. Merging and building packages.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'checkbox/lib/template.py'
--- checkbox/lib/template.py 2012-06-01 13:35:12 +0000
+++ checkbox/lib/template.py 2012-06-19 19:41:20 +0000
@@ -139,5 +139,5 @@
139 def load_filename(self, filename):139 def load_filename(self, filename):
140 logging.info("Loading elements from filename: %s", filename)140 logging.info("Loading elements from filename: %s", filename)
141141
142 file = open(filename, "r")142 file = open(filename, "r", encoding="utf-8")
143 return self.load_file(file, filename)143 return self.load_file(file, filename)
144144
=== modified file 'debian/changelog'
--- debian/changelog 2012-06-19 18:28:47 +0000
+++ debian/changelog 2012-06-19 19:41:20 +0000
@@ -38,6 +38,8 @@
38 hunting through process lists.38 hunting through process lists.
39 * [FEATURE] Added script and jobs to collect and attach output from39 * [FEATURE] Added script and jobs to collect and attach output from
40 alsa-info.sh.40 alsa-info.sh.
41 * Assume utf-8 encoding always, when opening template files.
42 (LP: #1015174)
4143
42 [Javier Collado]44 [Javier Collado]
43 * Submission screen in Qt interface updated to support certification client:45 * Submission screen in Qt interface updated to support certification client:
@@ -126,7 +128,7 @@
126 * jobs/stress.txt.in: add OEM team's stress tests (including reboot and poweroff)128 * jobs/stress.txt.in: add OEM team's stress tests (including reboot and poweroff)
127 and log analysis jobs 129 and log analysis jobs
128130
129 -- Jeff Lane <jeff@ubuntu.com> Tue, 19 Jun 2012 14:02:37 -0400131 -- Daniel Manrique <roadmr@ubuntu.com> Tue, 19 Jun 2012 14:28:40 -0400
130132
131checkbox (0.13.8) precise; urgency=low133checkbox (0.13.8) precise; urgency=low
132134
133135
=== modified file 'plugins/message_info.py'
--- plugins/message_info.py 2012-06-01 21:38:37 +0000
+++ plugins/message_info.py 2012-06-19 19:41:20 +0000
@@ -125,7 +125,7 @@
125 self._manager.reactor.fire("report-messages", messages)125 self._manager.reactor.fire("report-messages", messages)
126126
127 def message_filename(self, filename):127 def message_filename(self, filename):
128 file = open(filename, "r")128 file = open(filename, "r", encoding="utf-8")
129 try:129 try:
130 self._manager.reactor.fire("message-file", file, filename)130 self._manager.reactor.fire("message-file", file, filename)
131 finally:131 finally:

Subscribers

People subscribed via source and target branches