From a2bf2667267ac84f8e3d34d70b613f9388a278cb Mon Sep 17 00:00:00 2001 From: Lexy Andati Date: Sat, 12 Sep 2020 05:53:24 +0200 Subject: [PATCH] Change temp dir location for html plots An attempt at #78 --- ragavi/ragavi.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ragavi/ragavi.py b/ragavi/ragavi.py index 776cba9..2d7ce3c 100644 --- a/ragavi/ragavi.py +++ b/ragavi/ragavi.py @@ -22,7 +22,6 @@ from pyrap.tables import table import ragavi.utils as vu - from ragavi import __version__ from ragavi.plotting import create_bk_fig, add_axis @@ -1522,6 +1521,16 @@ def gen_checkbox_labels(batch_size, num_leg_objs, antnames): ################## Saving Plot funcs ################################### +def set_tempdir(name): + """Set the current dir as the temp dir also""" + import tempfile + if os.path.isfile(name): + t_dir = os.path.dirname(os.path.abspath(name)) + else: + t_dir = name + tempfile.tempdir = t_dir + + def save_html(name, plot_layout): """Save plots in HTML format @@ -2191,6 +2200,9 @@ def main(**kwargs): if _NB_RENDER_: return final_layout else: + # set output dir to temp dir also + set_tempdir((options.html_name or os.getcwd())) + if options.image_name and options.html_name: save_html(options.html_name, final_layout) save_static_image(fname=options.image_name, figs=final_plots,