Skip to content
Snippets Groups Projects
Commit b967d791 authored by Kien Le's avatar Kien Le
Browse files

Write log header only when needed

parent baa644fc
No related branches found
No related tags found
1 merge request!199Write log file
This commit is part of merge request !199. Comments created here will be created in the context of that merge request.
...@@ -138,13 +138,21 @@ class RT130(GeneralData): ...@@ -138,13 +138,21 @@ class RT130(GeneralData):
for key in self.log_data: for key in self.log_data:
if key == 'TEXT': if key == 'TEXT':
continue continue
current_time = datetime.datetime.now().ctime() soh_header = ''
soh_header = (f'SOHStationViewer: v{SOFTWARE_VERSION} '
f'Run time (UTC): {current_time}\n')
soh_footer = '' soh_footer = ''
soh_messages = self.log_data[key]['SOH']
possible_programs = ['logpeek', 'SOHStationViewer', 'rt2ms']
message_has_header = any(soh_messages[0].startswith(program)
for program
in possible_programs)
if not message_has_header:
current_time = datetime.datetime.now().ctime()
soh_header = (f'SOHStationViewer: v{SOFTWARE_VERSION} '
f'Run time (UTC): {current_time}\n')
if self.include_masspos_in_soh_messages: if self.include_masspos_in_soh_messages:
soh_footer += '\n\nMass-positions:\n' soh_footer += '\n\nMass-positions:\n'
mass_pos_lines = [] mass_pos_lines = []
soh_messages = self.log_data[key]['SOH']
for chan in self.mass_pos_data[key]: for chan in self.mass_pos_data[key]:
chan_data = self.mass_pos_data[key][chan] chan_data = self.mass_pos_data[key][chan]
# We combined all data into one trace above # We combined all data into one trace above
...@@ -158,7 +166,6 @@ class RT130(GeneralData): ...@@ -158,7 +166,6 @@ class RT130(GeneralData):
] ]
mass_pos_lines.extend(formatted_lines) mass_pos_lines.extend(formatted_lines)
soh_footer += '\n'.join(mass_pos_lines) soh_footer += '\n'.join(mass_pos_lines)
soh_messages = self.log_data[key]['SOH']
soh_messages[0] = soh_header + soh_messages[0] + soh_footer soh_messages[0] = soh_header + soh_messages[0] + soh_footer
def read_log_files(self): def read_log_files(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment