From d47b8ebec1f854eee21b11e6b26ea9064ed14cbc Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Sun, 26 Apr 2020 21:27:50 +0200 Subject: [PATCH] log formatting improved --- sendreceive/obsw_command_sender_receiver.py | 2 +- tc/obsw_pus_tc_packer.py | 2 +- utility/obsw_tmtc_printer.py | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sendreceive/obsw_command_sender_receiver.py b/sendreceive/obsw_command_sender_receiver.py index f30e18c..48232da 100644 --- a/sendreceive/obsw_command_sender_receiver.py +++ b/sendreceive/obsw_command_sender_receiver.py @@ -118,7 +118,7 @@ class CommandSenderReceiver: time.sleep(wait_time) elif queue_entry_first == "print": print_string = queue_entry_second - self._tmtc_printer.print_string(print_string) + self._tmtc_printer.print_string(print_string, True) elif queue_entry_first == "export": export_name = queue_entry_second self._tmtc_printer.add_print_buffer_to_buffer_list() diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py index adbee62..ccb66f2 100644 --- a/tc/obsw_pus_tc_packer.py +++ b/tc/obsw_pus_tc_packer.py @@ -107,7 +107,7 @@ def pack_service9_test_into(tc_queue: TcQueueT) -> TcQueueT: def pack_service17_test_into(tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Service 17.")) + tc_queue.appendleft(("print", "Testing Service 17\r")) # ping test tc_queue.appendleft(("print", "Testing Service 17: Ping Test")) command = PusTelecommand(service=17, subservice=1, ssc=1700) diff --git a/utility/obsw_tmtc_printer.py b/utility/obsw_tmtc_printer.py index 3beaff4..5ed2be3 100644 --- a/utility/obsw_tmtc_printer.py +++ b/utility/obsw_tmtc_printer.py @@ -220,23 +220,32 @@ class TmTcPrinter: str_to_print += ']' return str_to_print - def print_string(self, string: str): + def print_string(self, string: str, add_cr_to_file_buffer: bool = False): """ Print a string and adds it to the file buffer. :param string: + :param add_cr_to_file_buffer: :return: """ self.__print_buffer = string logger.info(self.__print_buffer) if self.do_print_to_file: - self.add_print_buffer_to_file_buffer() + self.add_print_buffer_to_file_buffer(add_cr_to_file_buffer) + + def add_to_print_string(self, string_to_add: str=""): + self.__print_buffer += string_to_add - def add_print_buffer_to_file_buffer(self): + def add_print_buffer_to_file_buffer(self, add_cr_to_file_buffer: bool = False): """ :return: """ if self.do_print_to_file: - self.__file_buffer = self.__file_buffer + self.__print_buffer + "\r\n" + if add_cr_to_file_buffer: + self.__file_buffer += self.__print_buffer + "\r\n\r\n" + else: + self.__file_buffer += self.__print_buffer + "\r\n" + + def add_print_buffer_to_buffer_list(self): self.file_buffer_list.append(self.__file_buffer) -- GitLab