From 42d578da76255f5c5c7354569063c04b4a862fe5 Mon Sep 17 00:00:00 2001 From: John Burwell Date: Thu, 31 Aug 2023 13:02:10 -0500 Subject: [PATCH] attempt chunked output to avoid message too long error --- rsbbs/console.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/rsbbs/console.py b/rsbbs/console.py index ce0fa1a..191585f 100644 --- a/rsbbs/console.py +++ b/rsbbs/console.py @@ -105,14 +105,26 @@ class Console(): input_lines.append(input_line) return ''.join(input_lines) + def write_chunk(self, chunk: str) -> None: + """Write a chunk of data to stdout. + + :param output: the chunk to write to stdout + + """ + sys.stdout.write(chunk + '\r\n') + sys.stdout.flush() + def write_output(self, output: str) -> None: """Write something to stdout. :param output: the string to write to stdout """ - sys.stdout.write(output + '\r\n') - sys.stdout.flush() + chunk_size = 256 # Adjust the chunk size as needed + + for i in range(0, len(output), chunk_size): + chunk = output[i:i + chunk_size] + self.write_chunk(chunk) def print_configuration(self) -> None: """Print the current running configuration.