mirror of
https://github.com/Rucknium/xmrpeers.git
synced 2024-11-16 18:37:36 +00:00
Moved archive
to from required to suggested packages
and edited code to check if it is installed, then perform the appropriate operations in compress.log(). On Linux, `archive` needs some system packages to be installed, so it is better as a suggested package.
This commit is contained in:
parent
d6f3672015
commit
e4fc8c5222
3 changed files with 25 additions and 13 deletions
|
@ -25,9 +25,9 @@ Imports:
|
||||||
parallelly,
|
parallelly,
|
||||||
future,
|
future,
|
||||||
future.apply,
|
future.apply,
|
||||||
qs,
|
qs
|
||||||
archive
|
|
||||||
Suggests:
|
Suggests:
|
||||||
|
archive,
|
||||||
testthat (>= 3.0.0),
|
testthat (>= 3.0.0),
|
||||||
withr
|
withr
|
||||||
Config/testthat/edition: 3
|
Config/testthat/edition: 3
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
export("ping.peers")
|
export("ping.peers")
|
||||||
export("get.p2p.log")
|
export("get.p2p.log")
|
||||||
export("compress.log")
|
export("compress.log")
|
||||||
importFrom("utils", "read.csv", "untar")
|
importFrom("utils", "read.csv", "untar", "installed.packages")
|
||||||
importFrom("stats", "complete.cases")
|
importFrom("stats", "complete.cases")
|
||||||
|
|
16
R/parse.R
16
R/parse.R
|
@ -263,6 +263,7 @@ compress.log <- function(bitmonero.dir = c("~/.bitmonero", "C:\\ProgramData\\bit
|
||||||
cat("Processing ", length(gz.files), " log files in ", tar.file, "...\n", sep = "")
|
cat("Processing ", length(gz.files), " log files in ", tar.file, "...\n", sep = "")
|
||||||
for (gz.file in gz.files) {
|
for (gz.file in gz.files) {
|
||||||
cat("Processing log file ", gz.file, " from ", tar.file, "...\n", sep = "")
|
cat("Processing log file ", gz.file, " from ", tar.file, "...\n", sep = "")
|
||||||
|
if ("archive" %in% installed.packages()[, 1]) {
|
||||||
gz.connection <- archive::archive_read(paste0(bitmonero.dir, "/", tar.file), file = gz.file)
|
gz.connection <- archive::archive_read(paste0(bitmonero.dir, "/", tar.file), file = gz.file)
|
||||||
gz.output <- readLines(gz.connection, skipNul = TRUE)
|
gz.output <- readLines(gz.connection, skipNul = TRUE)
|
||||||
# Cannot use data.table::fread() with a connection: https://github.com/Rdatatable/data.table/issues/561
|
# Cannot use data.table::fread() with a connection: https://github.com/Rdatatable/data.table/issues/561
|
||||||
|
@ -271,6 +272,16 @@ compress.log <- function(bitmonero.dir = c("~/.bitmonero", "C:\\ProgramData\\bit
|
||||||
rm(gz.output)
|
rm(gz.output)
|
||||||
close(gz.connection)
|
close(gz.connection)
|
||||||
# Close connection
|
# Close connection
|
||||||
|
} else {
|
||||||
|
tmp <- tempdir()
|
||||||
|
untar(paste0(bitmonero.dir, "/", tar.file), files = gz.file, exdir = tmp)
|
||||||
|
gz.output <- data.table::fread(paste0(bitmonero.dir, "/", gz.file), colClasses = "character",
|
||||||
|
header = FALSE, sep = NULL, blank.lines.skip = FALSE, showProgress = FALSE)[[1]]
|
||||||
|
data.table::fwrite(list(paste0(gz.file, ":", gz.output[grep(log.filter, gz.output)])),
|
||||||
|
file = output.file, append = TRUE, col.name = FALSE, showProgress = FALSE)
|
||||||
|
rm(gz.output)
|
||||||
|
unlink(paste0(tmp, "/", gz.file))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gc()
|
gc()
|
||||||
|
@ -279,7 +290,7 @@ compress.log <- function(bitmonero.dir = c("~/.bitmonero", "C:\\ProgramData\\bit
|
||||||
cat("Processing log file ", bitmonero.file, "...\n", sep = "")
|
cat("Processing log file ", bitmonero.file, "...\n", sep = "")
|
||||||
txt.output <- data.table::fread(paste0(bitmonero.dir, "/", bitmonero.file), colClasses = "character",
|
txt.output <- data.table::fread(paste0(bitmonero.dir, "/", bitmonero.file), colClasses = "character",
|
||||||
header = FALSE, sep = NULL, blank.lines.skip = FALSE, showProgress = FALSE)[[1]]
|
header = FALSE, sep = NULL, blank.lines.skip = FALSE, showProgress = FALSE)[[1]]
|
||||||
data.table::fwrite(list(paste0(gz.file, ":", txt.output[grep(log.filter, txt.output)])),
|
data.table::fwrite(list(paste0(bitmonero.file, ":", txt.output[grep(log.filter, txt.output)])),
|
||||||
file = output.file, append = TRUE, col.name = FALSE, showProgress = FALSE)
|
file = output.file, append = TRUE, col.name = FALSE, showProgress = FALSE)
|
||||||
rm(txt.output)
|
rm(txt.output)
|
||||||
}
|
}
|
||||||
|
@ -362,7 +373,8 @@ xzcompress <- function (filename, destname = sprintf("%s.xz", filename), tempora
|
||||||
nbytes <- nbytes + n
|
nbytes <- nbytes + n
|
||||||
writeBin(bfr, con = out, size = 1L)
|
writeBin(bfr, con = out, size = 1L)
|
||||||
bfr <- NULL
|
bfr <- NULL
|
||||||
cat( formatC(round(nbytes / 10^9, 1), digits = 1, flag = "#"), " GB compressed...\r", sep = "")
|
cat( formatC(round(nbytes / 10^9, 1), width = 2, digits = 1, flag = "#",
|
||||||
|
format = "f"), " GB compressed...\r", sep = "")
|
||||||
# Added this. \r is to delete previous line.
|
# Added this. \r is to delete previous line.
|
||||||
}
|
}
|
||||||
outComplete <- TRUE
|
outComplete <- TRUE
|
||||||
|
|
Loading…
Reference in a new issue