Skip to content

Commit

Permalink
Handle bad characters in log files from AMS (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
melund authored Dec 1, 2023
1 parent 9be6ac9 commit c5a9c72
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions anypytools/abcutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,9 @@ def _worker(self, task, task_queue):
delete=False,
) as fh:
task.logfile = fh.name
with open(task.logfile, "w+") as logfile:
with open(
task.logfile, "w+", encoding="utf8", errors="backslashreplace"
) as logfile:
logfile.write("########### MACRO #############\n")
logfile.write("\n".join(task.macro))
logfile.write("\n\n######### OUTPUT LOG ##########")
Expand Down Expand Up @@ -915,9 +917,13 @@ def _worker(self, task, task_queue):
raise e
finally:
logfile.seek(0)

try:
readout = logfile.read()
except Exception as e:
print(logfile.name)
raise e
task.output = parse_anybodycon_output(
logfile.read(),
readout,
self.ignore_errors,
self.warnings_to_include,
fatal_warnings=self.fatal_warnings,
Expand Down

0 comments on commit c5a9c72

Please sign in to comment.