[PATCH 4/5] Sanitizing strings before passing them to the logging system.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The logging system encodes messages using the utf-8 encoding by
default. So sometimes it's necessary to re-encode lines when
non unicode characters are thrown up by the command outputs.

This patch re-encodes lines of text that will be passed to the
logging system on the track_process function on kvm_utils.
---
 client/tests/kvm_runtest_2/kvm_utils.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm_runtest_2/kvm_utils.py b/client/tests/kvm_runtest_2/kvm_utils.py
index bcc80a1..9ef5954 100644
--- a/client/tests/kvm_runtest_2/kvm_utils.py
+++ b/client/tests/kvm_runtest_2/kvm_utils.py
@@ -755,6 +755,9 @@ def track_process(sub, status_output=None, term_func=None, stdout_func=None,
         # Call stdout_func with the returned text
         if stdout_func:
             text = prefix + text.strip()
+            # We need to sanitize the text before passing it to the logging
+            # system
+            text = text.decode('utf-8', 'replace')
             stdout_func(text)
 
 
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux