diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-10-01 10:40:47 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-07 00:11:20 +0100 |
commit | 48e5579c1e0b382f890ef533ff39ad5f3a3390cf (patch) | |
tree | 6a85817142e717af873f0a0baadf11416c051687 /meta | |
parent | 1f9945266ad8f780f4ba14e66759a218d9f95762 (diff) | |
download | poky-48e5579c1e0b382f890ef533ff39ad5f3a3390cf.tar.gz |
oeqa/utils/qemurunner: Add support for Unicode from qemu
The current state of qemurunner will drop the Unicode
characters received from qemu, this is because error
report web had problems with Unicode characters; now
that the server support Unicode, it is possible to
log all the output from qemu. So far the only Unicode
character seen is the copyright symbol.
This patch allows to get Unicode characters from the qemu
target and save the log in an UTF-8 file for latter use.
[YOCTO #8225]
(From OE-Core rev: 4708a55879e1d8fe830d230b0621029cc40de9c3)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 9c878bc707..6fe75b8a08 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -15,11 +15,18 @@ import select | |||
15 | import errno | 15 | import errno |
16 | import string | 16 | import string |
17 | import threading | 17 | import threading |
18 | import codecs | ||
18 | from oeqa.utils.dump import HostDumper | 19 | from oeqa.utils.dump import HostDumper |
19 | 20 | ||
20 | import logging | 21 | import logging |
21 | logger = logging.getLogger("BitBake.QemuRunner") | 22 | logger = logging.getLogger("BitBake.QemuRunner") |
22 | 23 | ||
24 | # Get Unicode non printable control chars | ||
25 | control_range = range(0,32)+range(127,160) | ||
26 | control_chars = [unichr(x) for x in control_range | ||
27 | if unichr(x) not in string.printable] | ||
28 | re_control_char = re.compile('[%s]' % re.escape("".join(control_chars))) | ||
29 | |||
23 | class QemuRunner: | 30 | class QemuRunner: |
24 | 31 | ||
25 | def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds): | 32 | def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds): |
@@ -63,9 +70,9 @@ class QemuRunner: | |||
63 | def log(self, msg): | 70 | def log(self, msg): |
64 | if self.logfile: | 71 | if self.logfile: |
65 | # It is needed to sanitize the data received from qemu | 72 | # It is needed to sanitize the data received from qemu |
66 | # because is possible to have control characters or Unicode | 73 | # because is possible to have control characters |
67 | msg = "".join(filter(lambda x:x in string.printable, msg)) | 74 | msg = re_control_char.sub('', unicode(msg, 'utf-8')) |
68 | with open(self.logfile, "a") as f: | 75 | with codecs.open(self.logfile, "a", encoding="utf-8") as f: |
69 | f.write("%s" % msg) | 76 | f.write("%s" % msg) |
70 | 77 | ||
71 | def getOutput(self, o): | 78 | def getOutput(self, o): |
@@ -176,7 +183,7 @@ class QemuRunner: | |||
176 | cmdline = p.read() | 183 | cmdline = p.read() |
177 | # It is needed to sanitize the data received | 184 | # It is needed to sanitize the data received |
178 | # because is possible to have control characters | 185 | # because is possible to have control characters |
179 | cmdline = "".join(filter(lambda x:x in string.printable, cmdline)) | 186 | cmdline = re_control_char.sub('', cmdline) |
180 | try: | 187 | try: |
181 | ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) | 188 | ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1]) |
182 | if not ips or len(ips) != 3: | 189 | if not ips or len(ips) != 3: |