Commit c7f5807e authored by Samuel GAIST's avatar Samuel GAIST

[experiments] Improve output writing

If a string is retrieved from the plotter, write text
else binary.
parent 06cf8090
......@@ -648,6 +648,7 @@ def plot_impl(configuration, names, remote, show, output_folder):
logger.warning("Default parameters not found")
return {}
mimetypes.init()
for exp_name, results in data_to_plot.items():
for result_name, result_data in results.items():
result_type = result_data["type"]
......@@ -685,13 +686,17 @@ def plot_impl(configuration, names, remote, show, output_folder):
content_type = getattr(runner.obj, "content_type", "image/png")
extension = mimetypes.guess_extension(content_type)
outputimage_name = "{}_{}{}".format(
outputfile_name = "{}_{}{}".format(
exp_name.replace("/", "_"), result_name, extension
)
output_path = os.path.realpath(
os.path.join(output_folder, outputimage_name)
)
with open(output_path, "wb") as fh:
output_path = os.path.realpath(os.path.join(output_folder, outputfile_name))
if isinstance(plotter_data, str):
mode = "w"
else:
mode = "wb"
with open(output_path, mode) as fh:
fh.write(plotter_data)
indentation = 4
logger.info("%ssaved image `%s'...", indentation * " ", output_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment