Selaa lähdekoodia

Log gathertweet action start/end

simplify
Garrick Aden-Buie 7 vuotta sitten
vanhempi
commit
26ee9c1e5c
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. +5
    -2
      inst/gathertweet.R

+ 5
- 2
inst/gathertweet.R Näytä tiedosto

} }


library(gathertweet) library(gathertweet)
action <- names(Filter(isTRUE, args[c("search", "update")]))


if (args$polite) { if (args$polite) {
lockfile <- paste0(".gathertweet_", lockfile <- paste0(".gathertweet_",
digest::digest(args[c("file", "search", "update")]), digest::digest(args[c("file", "search", "update")]),
".lock") ".lock")
lck <- filelock::lock(lockfile, exclusive = TRUE, timeout = 0) lck <- filelock::lock(lockfile, exclusive = TRUE, timeout = 0)
action <- names(Filter(isTRUE, args[c("search", "update")]))
gathertweet:::stopifnot_locked(lck, "Another gathertweet {action} process is currently running for {args$file}") gathertweet:::stopifnot_locked(lck, "Another gathertweet {action} process is currently running for {args$file}")
} }


log_info("---- gathertweet {action} start ----")

# Search ------------------------------------------------------------------ # Search ------------------------------------------------------------------
if (isTRUE(args$search)) { if (isTRUE(args$search)) {


if (args$backup) backup_tweets(args$file, backup_dir = args[["backup-dir"]]) if (args$backup) backup_tweets(args$file, backup_dir = args[["backup-dir"]])
tweets <- save_tweets(tweets, args$file) tweets <- save_tweets(tweets, args$file)
log_debug("Total of {nrow(tweets)} tweets in {args$file}") log_debug("Total of {nrow(tweets)} tweets in {args$file}")
log_info("Tweet update complete")


} }


filelock::unlock(lck) filelock::unlock(lck)
unlink(lockfile) unlink(lockfile)
} }

log_info("---- gathertweet {action} complete ----")

Loading…
Peruuta
Tallenna