Skip to content

Commit

Permalink
Robustness no internet (#255)
Browse files Browse the repository at this point in the history
fix #175
  • Loading branch information
maelle authored Nov 21, 2019
1 parent 344bd7e commit 4576f69
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
11 changes: 10 additions & 1 deletion R/codemeta_readme.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ get_pkg_name <- function(entry) {

url_onboarded_json <- "https://badges.ropensci.org/json/onboarded.json"

reviews <- jsonlite::read_json(url_onboarded_json)
reviews <- suppressWarnings(
try(jsonlite::read_json(url_onboarded_json),
silent = TRUE))

if (is(reviews, "try-error")) {
return(tibble::tibble(
review = 0,
package = "Nope"
))
}

tibble::tibble(
review = purrr::map_dbl(reviews, "iss_no"),
Expand Down
6 changes: 6 additions & 0 deletions R/create_codemeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ create_codemeta <- function(
...
) {

if (!pingr::is_online()) {
if (verbose) {
message("Your computer is not online. codemetar will find less metadata than if it were.")
}
}

## looks like we got a package name/path or Description file
if (is.character(pkg)) {

Expand Down
6 changes: 4 additions & 2 deletions R/guess_provider.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
## cache available packages
.CRAN <- function() {

available_source_packages("https://cran.rstudio.com")
suppressWarnings(
available_source_packages("https://cran.rstudio.com"))
}

# .BIOC ------------------------------------------------------------------------
.BIOC <- function() {

available_source_packages("https://www.bioconductor.org/packages/release/bioc")
suppressWarnings(
available_source_packages("https://www.bioconductor.org/packages/release/bioc"))
}

# CRAN -------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ get_url_status_code <- function(url) {
# check_urls -------------------------------------------------------------------
check_urls <- function(urls) {

if (!pingr::is_online()) {

return("")
}

messages <- do.call(rbind, lapply(urls, get_url_status_code))

failed <- (messages$message != "All good")
Expand Down

0 comments on commit 4576f69

Please sign in to comment.