diff options
author | Michael Weiser <michael.weiser@gmx.de> | 2019-04-15 15:36:54 +0000 |
---|---|---|
committer | Michael Weiser <michael.weiser@gmx.de> | 2019-04-15 15:36:54 +0000 |
commit | bb6bbe1b586656cfcf1e61cd5cc0132eb8b5b5fa (patch) | |
tree | 67a962f517ea5676a65c6c5280c9a59305d37b99 /peekaboo/sample.py | |
parent | 91fe84aea999d38cab12a4cf6338f29bb34a4c02 (diff) |
Don't write empty reports
Only dump the reports if there's actually something in them. Include a
terminating newline as to not garble succeeding content.
Incidentally avoids one of those dreaded "must be unicode not str"
exceptions if the report is empty - there seem to be some corner cases
left to understand there.
Diffstat (limited to 'peekaboo/sample.py')
-rw-r--r-- | peekaboo/sample.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/peekaboo/sample.py b/peekaboo/sample.py index 8b4b071..b433752 100644 --- a/peekaboo/sample.py +++ b/peekaboo/sample.py @@ -336,8 +336,10 @@ class Sample(object): peekaboo_report = os.path.join(dump_dir, filename + '_report.txt') try: with open(peekaboo_report, 'w+') as pr_file: - pr_file.write('\n'.join(self.__report)) - pr_file.write('\n'.join(self.__internal_report)) + if self.__report: + pr_file.write('\n'.join(self.__report + [""])) + if self.__internal_report: + pr_file.write('\n'.join(self.__internal_report + [""])) except (OSError, IOError) as error: logger.error('Failure to write report file %s: %s', peekaboo_report, error) |