Skip to content

Commit 3baba34

Browse files
committed
apply plotsbase_tmpdir to all db
1 parent d653366 commit 3baba34

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

PlotsBase/src/animation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end
1515

1616
const ANIM_PATTERN = "plots-anim-%06d.png"
1717

18-
Animation(dir = convert(String, mktempdir())) = Animation(dir, String[])
18+
Animation(dir = convert(String, mktempdir(plotsbase_tmpdir()))) = Animation(dir, String[])
1919

2020
"""
2121
frame(animation[, plot])
@@ -32,7 +32,7 @@ anim_filename(ext, parent = nothing) =
3232
if isijulia()
3333
"tmp"
3434
else
35-
tempname(parent nothing ? tempdir() : parent)
35+
tempname(parent nothing ? tempdir(plotsbase_tmpdir()) : parent)
3636
end * ext
3737

3838
giffn(parent = nothing) = anim_filename(".gif", parent)

PlotsBase/src/init.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ macro precompile_backend(backend_package)
129129
n = length(PlotsBase._examples)
130130
imports = sizehint!(Expr[], n)
131131
examples = sizehint!(Expr[], 10n)
132-
scratch_dir = mktempdir()
132+
scratch_dir = mktempdir(plotsbase_tmpdir())
133133
for i in setdiff(
134134
1:n,
135135
PlotsBase._backend_skips[backend_name()],

PlotsBase/src/utils.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# browsers can have issue opening files in /tmp (chromium, firefox, ...), so let the user decide.
2+
plotsbase_tmpdir() = if haskey(ENV, "PLOTSBASE_TMPDIR")
3+
ENV["PLOTSBASE_TMPDIR"]
4+
else
5+
tempdir()
6+
end
7+
18
treats_y_as_x(seriestype) =
29
seriestype in (:vline, :vspan, :histogram, :barhist, :stephist, :scatterhist)
310

PlotsBase/src/web.jl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,19 @@ embeddable_html(plt::AbstractPlot) = html_head(plt) * html_body(plt)
2323

2424
function open_browser_window(filename::AbstractString)
2525
@static if Sys.isapple()
26-
return run(`open $(filename)`)
26+
return run(`open $filename`)
2727
elseif Sys.islinux() || Sys.isbsd() # Sys.isbsd() addition is as yet untested, but based on suggestion in https://github.com/JuliaPlots/Plots.jl/issues/681
28-
return run(`xdg-open $(filename)`)
28+
return run(`xdg-open $filename`)
2929
elseif Sys.iswindows()
30-
return run(`$(ENV["COMSPEC"]) /c start "" "$(filename)"`)
30+
return run(`$(ENV["COMSPEC"]) /c start "" "$filename"`)
3131
else
3232
@warn "Unknown OS... cannot open browser window."
3333
end
3434
end
3535

36-
# browsers can have issue opening files in /tmp (chromium, firefox, ...), let the user decide.
37-
html_tempdir() = if haskey(ENV, "PLOTSBASE_TMPDIR")
38-
ENV["PLOTSBASE_TMPDIR"]
39-
else
40-
tempdir()
41-
end
42-
4336
function write_temp_html(plt::AbstractPlot)
4437
html = standalone_html(plt; title = plt.attr[:window_title])
45-
filename = tempname(html_tempdir()) * ".html"
38+
filename = tempname(plotsbase_tmpdir()) * ".html"
4639
write(filename, html)
4740
return filename
4841
end
@@ -69,7 +62,7 @@ function show_png_from_html(io::IO, plt::AbstractPlot)
6962
html_fn = write_temp_html(plt)
7063

7164
# convert that html file to a temporary png file using wkhtmltoimage
72-
png_fn = tempname(html_tempdir()) * ".png"
65+
png_fn = tempname(plotsbase_tmpdir()) * ".png"
7366
w, h = plt.attr[:size]
7467
html_to_png(html_fn, png_fn, w, h)
7568

0 commit comments

Comments
 (0)