summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py15
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
import errno
import string
import threading
+import codecs
from oeqa.utils.dump import HostDumper
import logging
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:
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):
if self.logfile:
# It is needed to sanitize the data received from qemu
- # because is possible to have control characters or Unicode
- msg = "".join(filter(lambda x:x in string.printable, msg))
- with open(self.logfile, "a") as f:
+ # because is possible to have control characters
+ msg = re_control_char.sub('', unicode(msg, 'utf-8'))
+ with codecs.open(self.logfile, "a", encoding="utf-8") as f:
f.write("%s" % msg)
def getOutput(self, o):
@@ -176,7 +183,7 @@ class QemuRunner:
cmdline = p.read()
# It is needed to sanitize the data received
# because is possible to have control characters
- cmdline = "".join(filter(lambda x:x in string.printable, cmdline))
+ cmdline = re_control_char.sub('', cmdline)
try:
ips = re.findall("((?:[0-9]{1,3}\.){3}[0-9]{1,3})", cmdline.split("ip=")[1])
if not ips or len(ips) != 3: