Merge lp:~roadmr/checkbox/fix-gconf-resource into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Merged at revision: 1533
Proposed branch: lp:~roadmr/checkbox/fix-gconf-resource
Merge into: lp:checkbox
Diff against target: 66 lines (+10/-7)
2 files modified
debian/changelog (+3/-1)
scripts/gconf_resource (+7/-6)
To merge this branch: bzr merge lp:~roadmr/checkbox/fix-gconf-resource
Reviewer Review Type Date Requested Status
Marc Tardif (community) Approve
Review via email: mp+116664@code.launchpad.net

Description of the change

Fixes the attached bug by changing the decoding charset.

I moved a bit of code around to factor command execution out of the get_gconf function, mainly to ease testing. I didn't find a way or place to put a proper test of the function :( Suggestions welcome, but the code seems to work now. To test it, download the gconf.txt file from the bug (comment #3), and replace COMMAND with something like "cat gconf.txt". Change the encoding from ascii to utf-8 and viceversa to see things pass/fail.

To post a comment you must log in.
Revision history for this message
Marc Tardif (cr3) wrote :

Hm, I remember specifically setting the encoding to ascii but I was probably only thinking about the keys. I now see that the values can conceivably be encoded in utf-8!

The changes look good but I made a couple modifications while merging:

1. The parentheses around the check_output were not necessary for the arguments to be split on multiple lines.
2. The length of the command and its arguments was short, so they didn't really need to be split in the first place :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-07-24 18:45:55 +0000
+++ debian/changelog 2012-07-25 14:36:24 +0000
@@ -11,6 +11,8 @@
11 (LP: #1028065)11 (LP: #1028065)
12 * Instruct Chromium browser to accept file:// URLs so it can correctly12 * Instruct Chromium browser to accept file:// URLs so it can correctly
13 open the checkbox submission.xml report (LP: #1026614)13 open the checkbox submission.xml report (LP: #1026614)
14 * scripts/gconf_resource: decode gconf output as utf-8 rather than ascii
15 (LP: #1022593)
1416
15 [Jeff Marcom]17 [Jeff Marcom]
16 * Added timeout to job call for disk smart test.18 * Added timeout to job call for disk smart test.
@@ -18,7 +20,7 @@
18 [Marc Tardif]20 [Marc Tardif]
19 * Escaping encoded strings in udevadm output (LP: #1025381)21 * Escaping encoded strings in udevadm output (LP: #1025381)
2022
21 -- Daniel Manrique <roadmr@ubuntu.com> Tue, 24 Jul 2012 13:32:37 -040023 -- Daniel Manrique <roadmr@ubuntu.com> Wed, 25 Jul 2012 10:22:40 -0400
2224
23checkbox (0.14.2) quantal; urgency=low25checkbox (0.14.2) quantal; urgency=low
2426
2527
=== modified file 'scripts/gconf_resource'
--- scripts/gconf_resource 2012-05-31 20:43:58 +0000
+++ scripts/gconf_resource 2012-07-25 14:36:24 +0000
@@ -21,7 +21,7 @@
21import sys21import sys
22import posixpath22import posixpath
2323
24from subprocess import Popen, PIPE24from subprocess import check_output, PIPE
2525
26from checkbox.lib.conversion import string_to_type26from checkbox.lib.conversion import string_to_type
2727
@@ -33,7 +33,7 @@
33SOURCE = "~/.gconf"33SOURCE = "~/.gconf"
3434
3535
36def get_gconf(command):36def get_gconf(output):
37 id = None37 id = None
38 id_pattern = re.compile(r"\s+(?P<id>\/.+):")38 id_pattern = re.compile(r"\s+(?P<id>\/.+):")
39 key_value_pattern = re.compile(r"\s+(?P<key>[\w\-]+) = (?P<value>.*)")39 key_value_pattern = re.compile(r"\s+(?P<key>[\w\-]+) = (?P<value>.*)")
@@ -42,9 +42,7 @@
42 # TODO: add support for multi-line values42 # TODO: add support for multi-line values
4343
44 gconf = {}44 gconf = {}
45 output = (Popen(command, stdout=PIPE, stderr=PIPE, shell=True)45 for line in output.decode("utf-8").split("\n"):
46 .communicate()[0])
47 for line in output.decode("ascii").split("\n"):
48 if not line:46 if not line:
49 continue47 continue
5048
@@ -80,7 +78,10 @@
80def main():78def main():
81 source = posixpath.expanduser(SOURCE)79 source = posixpath.expanduser(SOURCE)
82 command = COMMAND.replace("$source", source)80 command = COMMAND.replace("$source", source)
83 gconf = get_gconf(command)81 command_output = (check_output(command,
82 stderr=PIPE,
83 shell=True))
84 gconf = get_gconf(command_output)
8485
85 for name, value in gconf.items():86 for name, value in gconf.items():
86 print("name: %s" % name)87 print("name: %s" % name)

Subscribers

People subscribed via source and target branches