-
Notifications
You must be signed in to change notification settings - Fork 0
/
finbif2gbif.R
60 lines (35 loc) · 918 Bytes
/
finbif2gbif.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
dir.create("logs", showWarnings = FALSE)
log_file_name <- sprintf("logs/update-%s.txt", Sys.Date())
log_file <- file(log_file_name, open = "wt")
sink(log_file)
sink(log_file, type = "message")
if (!file.exists("config.yml")) {
invisible(file.copy("../config.yml", "."))
}
if (!dir.exists("stage")) {
dir.create("stage")
}
res <- tryCatch(
{
source("../update_collections.R")
"true"
},
error = function(e) {
message(sprintf("ERROR [%s] %s", format(Sys.time()), e$message))
"false"
}
)
system2(
"rclone",
c(
"sync",
"\"archives/split\"",
sprintf("\"default:hy-7088-finbif2gbif-%s\"", Sys.getenv("BRANCH"))
)
)
dir.create("status", showWarnings = FALSE)
cat(res, file = "status/success.txt")
cat(format(Sys.time(), usetz = TRUE), file = "status/last-update.txt")
sink(type = "message")
sink()
file.copy(log_file_name, "logs/update-latest.txt", TRUE)