Skip to content

Commit

Permalink
Fix metrics report, when top commands contain double quotes (#336)
Browse files Browse the repository at this point in the history
* Remove double quotes from cmd

* Correctly escape double quotes in metrics report
  • Loading branch information
alexander-veit authored Sep 27, 2021
1 parent c600b98 commit 51677a8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tibanna/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ def write_to_csv(self, csv_file, metric='cpu', delimiter=',', colname_for_timest
last_minute = 5
with open(csv_file, 'w') as fo:
# header
fo.write(delimiter.join([colname_for_timestamps] + [Top.wrap_in_double_quotes(cmd) for cmd in self.commands]))
# we have to escape any double quotes that are present in the cmd, before wrapping it in double quotes. Otherwise we
# will get incorrect column counts when creating the metrics report.
fo.write(delimiter.join([colname_for_timestamps] + [Top.wrap_in_double_quotes(cmd.replace('"', '""')) for cmd in self.commands]))
fo.write('\n')
# contents
# skip timepoints earlier than timestamp_start
Expand Down

0 comments on commit 51677a8

Please sign in to comment.