mirror of
https://git.yoctoproject.org/poky
synced 2026-09-16 09:49:35 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
1f9945266a
commit
48e5579c1e
@@ -15,11 +15,18 @@ import select
|
|||||||
import errno
|
import errno
|
||||||
import string
|
import string
|
||||||
import threading
|
import threading
|
||||||
|
import codecs
|
||||||
from oeqa.utils.dump import HostDumper
|
from oeqa.utils.dump import HostDumper
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger("BitBake.QemuRunner")
|
logger = logging.getLogger("BitBake.QemuRunner")
|
||||||
|
|
||||||
|
# Get Unicode non printable control chars
|
||||||
|
control_range = range(0,32)+range(127,160)
|
||||||
|
control_chars = [unichr(x) for x in control_range
|
||||||
|
if unichr(x) not in string.printable]
|
||||||
|
re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
|
||||||
|
|
||||||
class QemuRunner:
|
class QemuRunner:
|
||||||
|
|
||||||
def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds):
|
def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds):
|
||||||
@@ -63,9 +70,9 @@ class QemuRunner:
|
|||||||
def log(self, msg):
|
def log(self, msg):
|
||||||
if self.logfile:
|
if self.logfile:
|
||||||
# It is needed to sanitize the data received from qemu
|
# It is needed to sanitize the data received from qemu
|
||||||
# because is possible to have control characters or Unicode
|
# because is possible to have control characters
|
||||||
msg = "".join(filter(lambda x:x in string.printable, msg))
|
msg = re_control_char.sub('', unicode(msg, 'utf-8'))
|
||||||
with open(self.logfile, "a") as f:
|
with codecs.open(self.logfile, "a", encoding="utf-8") as f:
|
||||||
f.write("%s" % msg)
|
f.write("%s" % msg)
|
||||||
|
|
||||||
def getOutput(self, o):
|
def getOutput(self, o):
|
||||||
@@ -176,7 +183,7 @@ class QemuRunner:
|
|||||||
cmdline = p.read()
|
cmdline = p.read()
|
||||||
# It is needed to sanitize the data received
|
# It is needed to sanitize the data received
|
||||||
# because is possible to have control characters
|
# because is possible to have control characters
|
||||||
cmdline = "".join(filter(lambda x:x in string.printable, cmdline))
|
cmdline = re_control_char.sub('', cmdline)
|
||||||
try:
|
try:
|
||||||
ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
|
ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
|
||||||
if not ips or len(ips) != 3:
|
if not ips or len(ips) != 3:
|
||||||
|
|||||||
Reference in New Issue
Block a user