Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Water
dataRetrieval
Commits
40647168
Commit
40647168
authored
Nov 19, 2021
by
Laura A DeCicco
Browse files
Trying to get targets and proxies to work
parent
0833a037
Changes
4
Hide whitespace changes
Inline
Side-by-side
R/getWebServiceData.R
View file @
40647168
...
@@ -84,6 +84,9 @@ getWebServiceData <- function(obs_url, ...){
...
@@ -84,6 +84,9 @@ getWebServiceData <- function(obs_url, ...){
}
}
}
}
#' Create user agent
#'
#' @keywords internal
default_ua
<-
function
()
{
default_ua
<-
function
()
{
versions
<-
c
(
versions
<-
c
(
libcurl
=
curl
::
curl_version
()
$
version
,
libcurl
=
curl
::
curl_version
()
$
version
,
...
@@ -100,6 +103,24 @@ default_ua <- function() {
...
@@ -100,6 +103,24 @@ default_ua <- function() {
return
(
ua
)
return
(
ua
)
}
}
#' has_internet2
#'
#' Function to check for internet even if the user
#' is behind a proxy
#'
#' @keywords internal
#' @param obs_url character obs_url to check
has_internet_2
<-
function
(
obs_url
)
{
# For now, we know exactly where we're sending our queries
# But, if we expose a setter, we'll probably need to move it
# to the url construction, set a host in the package enviornment?,
# or come up with some better regex here:
host
<-
gsub
(
"^https://(?:www[.])?([^/]*).*$"
,
"\\1"
,
obs_url
)
!
is.null
(
curl
::
nslookup
(
host
,
error
=
FALSE
))
}
#' getting header information from a WQP query
#' getting header information from a WQP query
#'
#'
#'@param url the query url
#'@param url the query url
...
...
man/default_ua.Rd
0 → 100644
View file @
40647168
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/getWebServiceData.R
\name{default_ua}
\alias{default_ua}
\title{Create user agent}
\usage{
default_ua()
}
\description{
Create user agent
}
\keyword{internal}
man/has_internet_2.Rd
0 → 100644
View file @
40647168
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/getWebServiceData.R
\name{has_internet_2}
\alias{has_internet_2}
\title{has_internet2}
\usage{
has_internet_2(obs_url)
}
\arguments{
\item{obs_url}{character obs_url to check}
}
\description{
Function to check for internet even if the user
is behind a proxy
}
\keyword{internal}
tests/testthat/tests_general.R
View file @
40647168
...
@@ -49,10 +49,10 @@ test_that("General NWIS retrievals working", {
...
@@ -49,10 +49,10 @@ test_that("General NWIS retrievals working", {
expect_is
(
waterYearStat
$
parameter_cd
,
"character"
)
expect_is
(
waterYearStat
$
parameter_cd
,
"character"
)
#Empty data
#Empty data
# note....not empty anymore!
urlTest
<-
"https://nwis.waterservices.usgs.gov/nwis/iv/?site=11447650&format=waterml,1.1&ParameterCd=63680&startDT=2016-12-13&endDT=2016-12-13"
urlTest
<-
"https://nwis.waterservices.usgs.gov/nwis/iv/?site=11447650&format=waterml,1.1&ParameterCd=63680&startDT=2016-12-13&endDT=2016-12-13"
x
<-
importWaterML1
(
urlTest
)
x
<-
importWaterML1
(
urlTest
)
expect_
equal
(
names
(
x
),
c
(
"agency_cd"
,
"site_no"
,
"dateTime"
,
"tz_cd"
))
expect_
true
(
all
(
c
(
"agency_cd"
,
"site_no"
,
"dateTime"
,
"tz_cd"
)
%in%
names
(
x
))
)
#Test list:
#Test list:
args
<-
list
(
sites
=
"05114000"
,
service
=
"iv"
,
args
<-
list
(
sites
=
"05114000"
,
service
=
"iv"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment