Replace not recognized character isntead of raise exception
+import codecs
+
__author__ = 'Michal Ernst, Marcin Usielski'
__copyright__ = 'Copyright (C) 2018, Nokia'
__email__ = 'michal.ernst@nokia.com, marcin.usielski@nokia.com'
-import os
import re
import select
from threading import Event
@@ -51,6 +52,8 @@ class ThreadedTerminal(IOConnection):
"""Open ThreadedTerminal connection & start thread pulling data from it."""
if not self._terminal:
self._terminal = PtyProcessUnicode.spawn(self._cmd, dimensions=self.dimensions)
+ # need to not replace not unicode data instead of raise exception
+ self._terminal.decoder = codecs.getincrementaldecoder('utf-8')(errors='replace')
done = Event()
self.pulling_thread = TillDoneThread(target=self.pull_data,
@@ -100,6 +103,3 @@ class ThreadedTerminal(IOConnection):
except EOFError:
self._notify_on_disconnect()
pulling_done.set()
- except UnicodeDecodeError:
- # ignore data pack with character which cannot properly decode
- pass
