From 92f78d08281c99870c3b070e9db36eb6925ded4a Mon Sep 17 00:00:00 2001 From: "Emily.Markowitz" Date: Tue, 5 Jul 2022 12:23:52 -0700 Subject: [PATCH] added ftp code --- .gitignore | 2 ++ code/run.R | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c9191df..3d8d880 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ vignettes/*.pdf ConnectToOracle.R *.log /shapefiles/archive +/code/ftp_login.R + diff --git a/code/run.R b/code/run.R index d8b5746..bf79272 100644 --- a/code/run.R +++ b/code/run.R @@ -71,6 +71,9 @@ dir_wd <- "C:/Users/caitlin.akselrud/Work/survey-live-temperature-map/" source(file = paste0(dir_wd,"code/functions.R")) # source(file = paste0(dir_wd, "code/data_dl.R")) # you don't unnecessarily run this each time source(file = paste0(dir_wd, "code/data.R")) +if (googledrive_dl == TRUE) { + source(file = paste0(dir_wd, "code/ftp_login.R")) # removed in gitignore - ask for premission +} # Map -------------------------------------------------------------------------- # ## AI -------------------------------------------------------------------------- @@ -147,7 +150,25 @@ make_varplot_wrapper(maxyr = maxyr, # Daily plot # plot_anom = TRUE, # plot_mean = TRUE, # dir_wd = dir_wd) -# + +## send all current files to the FTP ------------------------------------------- +# vars here defined in ftp_login.R +dir_out <- paste0(getwd(),"/output/",maxyr,"_",SRVY,"/") +temp <- list.files(path = dir_out, pattern = "current_", full.names = FALSE) +dest <- dev_bs + +for (iiii in 1:length(temp)) { + print(temp[iiii]) + + RCurl::ftpUpload( + what = paste0(dir_out, "/", temp[iiii]), + asText = FALSE, + to = paste0(glue::glue("{protocol}://STOR@{server}/{dest}/", temp[iiii])), + userpwd = paste0(user,":", pass), + .opts=curlOptions(verbose=TRUE)) +} + + # NBS + EBS Maps -------------------------------------------------------------- SRVY <- "BS" @@ -212,7 +233,21 @@ make_varplot_wrapper(maxyr = maxyr, # Daily plot # plot_mean = TRUE, # dir_wd = dir_wd) - - +## send all current files to the FTP ------------------------------------------- +# vars here defined in ftp_login.R +dir_out <- paste0(getwd(),"/output/",maxyr,"_",SRVY,"/") +temp <- list.files(path = dir_out, pattern = "current_", full.names = FALSE) +dest <- dev_bs + +for (iiii in 1:length(temp)) { + print(temp[iiii]) + + RCurl::ftpUpload( + what = paste0(dir_out, "/", temp[iiii]), + asText = FALSE, + to = paste0(glue::glue("{protocol}://STOR@{server}/{dest}/", temp[iiii])), + userpwd = paste0(user,":", pass), + .opts=curlOptions(verbose=TRUE)) +} # sink()