From 62b3f88795853ba206a7cdf951f30212ecb554c2 Mon Sep 17 00:00:00 2001 From: chrisfacer Date: Mon, 27 Mar 2023 16:10:59 +1100 Subject: [PATCH] Check in uploadRScript if credentials are blank Can happen if you set up a new machine and forget to update your .Renviron. --- R/DataMart.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/R/DataMart.R b/R/DataMart.R index caad37d..4d55acc 100644 --- a/R/DataMart.R +++ b/R/DataMart.R @@ -519,10 +519,16 @@ uploadRScript <- function(r.code, { if (nzchar(send.to)) { - api.root = Sys.getenv(paste0("API_ROOT_", send.to)) - company.secret = Sys.getenv(paste0("COMPANY_SECRET_", send.to)) - client.id = Sys.getenv(paste0("CLIENT_ID_ ", send.to)) + api.root <- Sys.getenv(paste0("API_ROOT_", send.to)) + company.secret <- Sys.getenv(paste0("COMPANY_SECRET_", send.to)) + client.id <- Sys.getenv(paste0("CLIENT_ID_ ", send.to)) } + credentials <- setNames(c(api.root, company.secret, client.id), + c("api.root", "company.secret", "client.id")) + missing.credentials <- which(!nzchar(credentials)) + if (length(missing.credentials) > 0) + stop("Some of your API credentials are missing: ", paste0(names(credentials[missing.credentials]), collapse = ",")) + if (missing(filename)) stop(substitute(filename), " argument required as ", "filename to write in Displayr Drive is required.")