Closed rafapereirabr closed 3 years ago
Ok, I've now created / organized a new function is_online()
to check the Internet connection with Ipea server. See commit f8f1d4f. This will improve the error messages, but it does not entirely solve the problem, which seems to involve making changes to Ipea's server infrastructure. I'm checking this with our IT team.
CRAN will complain about options
setting. If this is necessary, we should use on.exit(options(warn = oldw))
right after setting it. But is it really necessary if we're already using suppressWarnings()
?
For some reason, suppressWarnings()
was not working in some cases when I first implemented in on geobr
. I've fixed the options
by adding on.exit(options(warn = oldw))
as you suggested. See a74f7b1.
Ok. I've added one internet connection test to download the metadata
file and another one to download the proper data set. No noticeble damage to download performance. Closing this issue in my next comit
I've updated the function to make it simpler and to follow CRAN policies. CRAN requires "fail gracefully with an informative message if the resource is not available or has changed (and not give a check warning nor error)."
#' Check internet connection with Ipea server
#'
#' @description
#' Checks if there is internet connection to Ipea server to download aop data.
#'
#' @param file_url A string with the file_url address of an aop dataset
#'
#' @return Logic `TRUE or `FALSE`.
#'
#' @export
#' @family support functions
#'
check_connection <- function(file_url = 'https://www.ipea.gov.br/geobr/aopdata/metadata/metadata.csv'){
# check internet connection
if (!curl::has_internet()) {
message("No internet connection.")
return(invisible(NULL))
}
# test server connection
# crul::ok(file_url)
if (httr::http_error(httr::GET(file_url))) {
message("Problem connecting to data server. Please try aopdata again in a few minutes.")
return(invisible(NULL))
}
}
I just got this from the CRAN team:
and a secont message from them: