Commit 920c988b authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Reprercussions of not stopping

parent ad557e7b
......@@ -44,7 +44,9 @@ importNGWMN <- function(input, asDateTime=FALSE, tz="UTC"){
raw <- TRUE
} else {
returnedDoc <- getWebServiceData(input, encoding='gzip')
if(is.null(returnedDoc)){
return(invisible(NULL))
}
returnedDoc <- xml_root(returnedDoc)
}
......
......@@ -103,6 +103,9 @@ importRDB1 <- function(obs_url, asDateTime=TRUE, convertType = TRUE, tz="UTC"){
doc <- getWebServiceData(obs_url,
httr::write_disk(f),
encoding='gzip')
if(is.null(doc)){
return(invisible(NULL))
}
if("warn" %in% names(attr(doc, "headerInfo"))){
data <- data.frame()
attr(data, "headerInfo") <- attr(doc,"headerInfo")
......
......@@ -52,6 +52,9 @@ importWQP <- function(obs_url, zip=TRUE, tz="UTC",
doc <- getWebServiceData(obs_url,
httr::write_disk(temp),
httr::accept("application/zip"))
if(is.null(doc)){
return(invisible(NULL))
}
headerInfo <- httr::headers(doc)
doc <- utils::unzip(temp, exdir=tempdir())
unlink(temp)
......@@ -59,6 +62,9 @@ importWQP <- function(obs_url, zip=TRUE, tz="UTC",
} else {
doc <- getWebServiceData(obs_url,
httr::accept("text/tsv"))
if(is.null(doc)){
return(invisible(NULL))
}
headerInfo <- attr(doc, "headerInfo")
}
......
......@@ -413,7 +413,12 @@ check_if_xml <- function(obs_url){
} else if(inherits(obs_url, c("xml_node", "xml_nodeset"))) {
returnedDoc <- obs_url
} else {
returnedDoc <- xml_root(getWebServiceData(obs_url, encoding='gzip'))
doc <- getWebServiceData(obs_url, encoding='gzip')
if(is.null(doc)){
return(invisible(NULL))
}
returnedDoc <- xml_root(doc)
}
return(returnedDoc)
}
\ No newline at end of file
......@@ -45,7 +45,9 @@ whatNWISsites <- function(...){
urlCall <- drURL('site',Access=pkg.env$access, arg.list = values)
rawData <- getWebServiceData(urlCall, encoding='gzip')
if(is.null(rawData)){
return(invisible(NULL))
}
doc <- xml_root(rawData)
siteCategories <- xml_children(doc)
retVal <- NULL
......
......@@ -161,6 +161,9 @@ whatWQPdata <- function(..., saveFile = tempfile()){
}
doc <- getWebServiceData(baseURL, httr::write_disk(saveFile_zip))
if(is.null(doc)){
return(invisible(NULL))
}
headerInfo <- attr(doc, "headerInfo")
if(headerInfo$`total-site-count` == 0){
......
......@@ -43,7 +43,7 @@ test_that("External importRDB1 tests", {
format="tsv",
statCd = "laksjd")
# And....now there's data there:
expect_error(importRDB1(url))
expect_null(importRDB1(url))
})
context("importRDB")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment