Skip to content

Commit

Permalink
added ftp code
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily.Markowitz authored and Emily.Markowitz committed Jul 5, 2022
1 parent 2639d88 commit 92f78d0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ vignettes/*.pdf
ConnectToOracle.R
*.log
/shapefiles/archive
/code/ftp_login.R

41 changes: 38 additions & 3 deletions code/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------------------------
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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()

0 comments on commit 92f78d0

Please sign in to comment.