better log

This commit is contained in:
François Briatte 2017-01-01 19:16:31 +01:00
parent 3f9c3556d0
commit d40d015424

39
check.r
View File

@ -31,30 +31,53 @@ l <- c(
stopifnot(length(l) == t)
l <- unique(l)
l <- unique(l) %>%
sort
cat(length(l), "unique\n")
sink("check.log", append = FALSE)
cat(as.character(Sys.time()), ": checking", length(l), "URLs\n\n")
sink()
for (i in l) {
if (!which(l == i) %% 50)
cat(length(l) - which(l == i), "left\n")
x <- try(GET(i) %>%
status_code,
silent = TRUE)
if (!"try-error" %in% class(x) && x != 200) {
cat("x")
cat("X")
sink("check.log", append = TRUE)
cat("\nURL:", i, "\nStatus code:", x, "\n")
cat(i, "\nStatus code:", x, "\n\n")
sink()
} else if("try-error" %in% class(x)) {
cat("x")
cat("?")
sink("check.log", append = TRUE)
cat("\nURL:", i, "\nFailed to access\n.")
cat(i, "\nFailed to access\n\n")
sink()
} else {
cat(".")
}
if (!which(l == i) %% 50)
cat("", length(l) - which(l == i), "left\n")
}
sink("check.log", append = TRUE)
cat(as.character(Sys.time()), ": done.\n")
sink()
cat("Found", str_count(readLines("check.log"), "^http:") %>%
sum,
"problems.\n")