Skip to content

Commit

Permalink
Check for data files before downloading them during build. (JuliaPlot…
Browse files Browse the repository at this point in the history
…s#237)

* If data files fail to download, check if the exist before providing an error.
Occassionally users
cannot use curl for downloading (e.g., firewall), and the workaround is to
download the files via web browser and place them in the proper location.

* Add a check to __init__() for warnings in build.log

Because @warn (and @info) do not write out to the REPL during the build phase,
this commit adds a check during __init__() for warnings in the build.log and
prompts the user to check it.
  • Loading branch information
jjstickel authored and sglyon committed Feb 2, 2019
1 parent 28dbe05 commit 5770d98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
19 changes: 17 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@ const _pkg_assets = joinpath(_pkg_root,"assets")

!isdir(_pkg_assets) && mkdir(_pkg_assets)

download("https://api.plot.ly/v2/plot-schema?sha1", joinpath(_pkg_deps,"plotschema.json"))
download("https://cdn.plot.ly/plotly-latest.min.js", joinpath(_pkg_assets,"plotly-latest.min.js"))
function datadown(thepath, thefile, theurl)
filepath = joinpath(thepath, thefile)
try
download(theurl, filepath)
catch
if isfile(filepath)
@warn("Failed to update $thefile, but you already have it. Things might continue to work, but if you would like to make sure you have the latest version of $thefile, use may use your web-browser to download it from $theurl and place it in $_pkg_deps.")
else
error("Failed to download $thefile from $theurl. You may use your web-browser to download it from $theurl and place it in $_pkg_deps.")
end
end
end

datadown(_pkg_deps, "plotschema.json",
"https://api.plot.ly/v2/plot-schema?sha1")
datadown(_pkg_assets, "plotly-latest.min.js",
"https://cdn.plot.ly/plotly-latest.min.js")

include("make_schema_docs.jl")
include("find_attr_groups.jl")
Expand Down
6 changes: 6 additions & 0 deletions src/PlotlyJS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ end

function __init__()
@require ORCA="47be7bcc-f1a6-5447-8b36-7eeeff7534fd" include("savefig_orca.jl")

_build_log = joinpath(_pkg_root, "deps", "build.log")
if occursin("Warning:", read(_build_log, String))
@warn("Warnings were generated during the last build of PlotlyJS: please check the build log at $_build_log")
end

if !isfile(_js_path)
@info("plotly.js javascript libary not found -- downloading now")
include(joinpath(_pkg_root, "deps", "build.jl"))
Expand Down

0 comments on commit 5770d98

Please sign in to comment.