Skip to content
Permalink
Browse files

suppress warnings on ftp parsing of servers, add test for GUI

  • Loading branch information
lbusett committed Aug 3, 2017
1 parent d03c183 commit 3775d6099bc359925d3dcbd96c2ffe8455502648
@@ -1,11 +1,13 @@
# Generated by roxygen2: do not edit by hand

export(MODIStest_check_md5)
export(MODIStsp)
export(MODIStsp_addindex)
export(MODIStsp_extract)
export(install_MODIStsp_launcher)
import(RCurl)
import(gWidgets)
import(gWidgetsRGtk2)
importFrom(RCurl,getURL)
importFrom(RJSONIO,fromJSON)
importFrom(RJSONIO,toJSON)
@@ -1,7 +1,8 @@
#' MODIStest_check_md5
#' @description internal function which tests if the output of a test is corresponds to the expected one.
#' @details When running in test mode, MODIStsp is expected to produce the same files
#' @details When running in test mode, MODIStsp is expected to produce the same files
#' @param test integer number of the performed test
#' @export
#' @return NULL
#'
#' @author Luigi Ranghetti, phD (2017) \email{ranghetti.l@@irea.cnr.it}
@@ -11,17 +12,17 @@
#' @importFrom RJSONIO fromJSON

MODIStest_check_md5 <- function(test) {

# charge expected values
exp_md5 <- as.data.frame(
fromJSON(system.file("Test_files", "tests_md5.json", package = "MODIStsp")),
fromJSON(system.file("Test_files", "tests_md5.json", package = "MODIStsp")),
stringsAsFactors=FALSE)
exp_md5 <- exp_md5[exp_md5$test==test,]

n_err <- 0 # counter of the number of files which do not pass the test
for (i in 1:nrow(exp_md5)) {
sel_file <- file.path(tempdir(),exp_md5[i,"filename"])

# in case of vrt files, delete the line with the reference of the filename
# (hdr files are not checked, since the corresponding dat is checked)
if (length(grep("\\.vrt$",sel_file))>0) {
@@ -39,12 +40,12 @@ MODIStest_check_md5 <- function(test) {
n_err <- n_err + 1
}
}

# summary
if (n_err == 0) {
message(paste0("Test ",test," runned succesfully.\n\n"))
} else {
message(paste0("Test ",test," failed on ",n_err,"/",nrow(exp_md5)," files.\n\n"))
}

}
@@ -128,7 +128,7 @@ lpdaac_getmod_dirs <- function(ftp, http, used_server = NA, user = user,

while (class(items) == "try-error") {

response <- try(httr::GET(ftp, timeout(10))) # send request to server
response <- try(suppressWarnings(httr::GET(ftp, timeout(10)))) # send request to server
# if error on response, retry
if (class(response) == "try-error") {
Sys.sleep(1)
@@ -152,7 +152,7 @@ lpdaac_getmod_dirs <- function(ftp, http, used_server = NA, user = user,
for (sel_year in items_1) {
ce <- 1; while (ce < 10) {
# try to download each year for 10 times
response_1[[sel_year]] <- try(httr::GET(paste0(ftp, sel_year, "/"), timeout(10)))
response_1[[sel_year]] <- suppressWarnings(try(httr::GET(paste0(ftp, sel_year, "/"), timeout(10))))
if (class(response_1[[sel_year]]) != "response") {
# if error on response, retry
Sys.sleep(1)
@@ -399,8 +399,8 @@ MODIStsp_process <- function(sel_prod, start_date, end_date, out_folder,
try(GET(paste0(remote_filename, ".xml"), authenticate(user, password),
timeout(240)))
} else if (download_server == "ftp") {
try(getURL(remote_filename, nobody = 1L, header = 1L,
.opts = list(timeout = 240, maxredirs = 5, verbose = TRUE)))
try((getURL(remote_filename, nobody = 1L, header = 1L,
.opts = list(timeout = 240, maxredirs = 5, verbose = FALSE))))
}
# Check if download was good: check class of xmldown and status of xmldown
if (class(size_string) == "try-error") {

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

0 comments on commit 3775d60

Please sign in to comment.
You can’t perform that action at this time.