Fix download by not using processx
This commit is contained in:
54
app.R
54
app.R
@@ -621,12 +621,50 @@ server <- function(input, output, session) {
|
||||
})
|
||||
|
||||
|
||||
export <- function(model, fPath) {
|
||||
|
||||
|
||||
return(zipFile)
|
||||
exportOrca <- function (p, file = "plot.png", format = tools::file_ext(file),
|
||||
scale = NULL, width = NULL, height = NULL,
|
||||
verbose = FALSE, debug = FALSE, safe = FALSE)
|
||||
{
|
||||
if (Sys.which("orca") == "") {
|
||||
stop("The orca command-line utility is required to use the `orca()` function.\n\n",
|
||||
"Follow the installation instructions here -- https://github.com/plotly/orca#installation",
|
||||
call. = FALSE)
|
||||
}
|
||||
|
||||
b <- plotly_build(p)
|
||||
|
||||
plotlyjs <- b$dependencies[sapply(b$dependencies, function(d) { d$name == "plotly-main" })][[1]]
|
||||
plotlyjs_file <- file.path(plotlyjs$src$file, plotlyjs$script)
|
||||
|
||||
args <- c(
|
||||
"graph", shQuote(jsonlite::toJSON(
|
||||
b$x[c("data", "layout")],
|
||||
digits = 50,
|
||||
auto_unbox = TRUE,
|
||||
force = TRUE,
|
||||
null = "null",
|
||||
na = "null"
|
||||
)),
|
||||
"-o", file,
|
||||
"--format", format,
|
||||
"--plotlyjs", plotlyjs_file
|
||||
)
|
||||
if (debug)
|
||||
args <- c(args, "--debug")
|
||||
if (verbose)
|
||||
args <- c(args, "--verbose")
|
||||
if (safe)
|
||||
args <- c(args, "--safe-mode")
|
||||
if (!is.null(scale))
|
||||
args <- c(args, "--scale", scale)
|
||||
if (!is.null(width))
|
||||
args <- c(args, "--width", width)
|
||||
if (!is.null(height))
|
||||
args <- c(args, "--height", height)
|
||||
|
||||
invisible(system2("orca", args))
|
||||
}
|
||||
|
||||
output$linkBackgroundData <- downloadHandler(
|
||||
filename = getModelName(),
|
||||
@@ -651,17 +689,13 @@ server <- function(input, output, session) {
|
||||
oldDir <- getwd()
|
||||
|
||||
tmp <- tempfile("")
|
||||
|
||||
print(tmp)
|
||||
dir.create(tmp)
|
||||
|
||||
setwd(tmp)
|
||||
|
||||
#Get the network graph
|
||||
l1 <- orca(prepPlot("ba", "Bio-Assemblage"), "layer1.png")
|
||||
l2 <- orca(prepPlot("op", "Output Processes"),"layer2.png")
|
||||
l3 <- orca(prepPlot("es", "Ecosystem Services"),"layer3.png")
|
||||
|
||||
l1 <- exportOrca(prepPlot("ba", "Bio-Assemblage"), "layer1.png")
|
||||
l2 <- exportOrca(prepPlot("op", "Output Processes"),"layer2.png")
|
||||
l3 <- exportOrca(prepPlot("es", "Ecosystem Services"),"layer3.png")
|
||||
|
||||
#Save pressure list, confidence levels, node and edge tables in xlsx
|
||||
l <- list(
|
||||
|
||||
Reference in New Issue
Block a user