twister: Remove newline suffix in BinaryHandler
Update the code that removes newline suffix in BinaryHandler for compatibility with python 3.8. Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/58335 Signed-off-by: Keith Short <keithshort@google.com>
This commit is contained in:
parent
95f82c60e5
commit
dfa992c596
1 changed files with 6 additions and 1 deletions
|
@ -176,6 +176,8 @@ class BinaryHandler(Handler):
|
||||||
self.line = proc.stdout.readline()
|
self.line = proc.stdout.readline()
|
||||||
|
|
||||||
def _output_handler(self, proc, harness):
|
def _output_handler(self, proc, harness):
|
||||||
|
suffix = '\\r\\n'
|
||||||
|
|
||||||
with open(self.log, "wt") as log_out_fp:
|
with open(self.log, "wt") as log_out_fp:
|
||||||
timeout_extended = False
|
timeout_extended = False
|
||||||
timeout_time = time.time() + self.timeout
|
timeout_time = time.time() + self.timeout
|
||||||
|
@ -188,7 +190,10 @@ class BinaryHandler(Handler):
|
||||||
reader_t.join(this_timeout)
|
reader_t.join(this_timeout)
|
||||||
if not reader_t.is_alive() and self.line != b"":
|
if not reader_t.is_alive() and self.line != b"":
|
||||||
line_decoded = self.line.decode('utf-8', "replace")
|
line_decoded = self.line.decode('utf-8', "replace")
|
||||||
stripped_line = line_decoded.rstrip().removesuffix('\\r\\n')
|
if line_decoded.endswith(suffix):
|
||||||
|
stripped_line = line_decoded[:-len(suffix)].rstrip()
|
||||||
|
else:
|
||||||
|
stripped_line = line_decoded.rstrip()
|
||||||
logger.debug("OUTPUT: %s", stripped_line)
|
logger.debug("OUTPUT: %s", stripped_line)
|
||||||
log_out_fp.write(line_decoded)
|
log_out_fp.write(line_decoded)
|
||||||
log_out_fp.flush()
|
log_out_fp.flush()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue