Skip to content

Commit

Permalink
Change temp dir location for html plots
Browse files Browse the repository at this point in the history
An attempt at #78
  • Loading branch information
Mulan-94 committed Sep 14, 2020
1 parent 367ad90 commit a2bf266
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ragavi/ragavi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a2bf266

Please sign in to comment.