Skip to content

Commit 02c1b11

Browse files
committed
#92 add stdout and stderr to system2
1 parent 1114858 commit 02c1b11

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rawrr
22
Type: Package
33
Title: Direct Access to Orbitrap Data and Beyond
4-
Version: 1.17.9
4+
Version: 1.17.10
55
Authors@R: c(person("Christian", "Panse",
66
email = "cp@fgcz.ethz.ch",
77
role = c("aut", "cre"),

R/rawrr.R

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,29 @@
8787
}
8888

8989
# system2 wrapper for readFileHeader, readSpectrum, readChromatogam
90+
# the system2 call will be used to generate R code
91+
#
92+
# param removeTempfile if \code{TRUE} the temp files for stdin and stdout are removed.
9093
.rawrrSystem2Source <-
91-
function(rawfile, input, rawrrArgs="scans", tmpdir=tempdir(),
92-
removeTempfile=TRUE){
94+
function(rawfile, input, rawrrArgs = "scans", tmpdir = tempdir(),
95+
removeTempfile = TRUE){
9396

9497
exe <- .rawrrAssembly()
9598

96-
tfi <- tempfile(tmpdir=tmpdir, fileext = ".txt")
97-
tfo <- tempfile(tmpdir=tmpdir, fileext = ".R")
98-
tfstdout <- tempfile(tmpdir=tmpdir, fileext = ".stdout")
99-
tfstderr <- tempfile(tmpdir=tmpdir, fileext = ".stderr" )
99+
tempfile(tmpdir = tmpdir, fileext = ".R") -> tfo
100+
tempfile(tmpdir = tmpdir, fileext = ".txt") -> tfi
101+
tempfile(tmpdir = tmpdir, fileext = ".stdout") -> tfstdout
102+
tempfile(tmpdir = tmpdir, fileext = ".stderr" ) -> tfstderr
100103

101-
cat(input, file = tfi, sep="\n")
104+
cat(input, file = tfi, sep = "\n")
102105
if(isFALSE(file.exists(tfi))){
103106
stop(paste0("No input file '", tfi, "' available!"))
104107
}
105108

106-
rvs <- system2(exe, args = c( shQuote(rawfile), rawrrArgs, shQuote(tfi), shQuote(tfo)), )
109+
system2(exe,
110+
args = c(shQuote(rawfile), rawrrArgs, shQuote(tfi), shQuote(tfo)),
111+
stdout = tfstdout,
112+
stderr = tfstderr) -> rvs
107113

108114
if (isFALSE(file.exists(tfo))){
109115
errmsg <- sprintf("Rcode file to parse does not exist. '%s' failed for an unknown reason.
@@ -115,7 +121,7 @@ Please check the debug files:\n\t%s\n\t%s\nand the System Requirements",
115121

116122

117123
e <- new.env()
118-
try(source(tfo, local=TRUE), silent = TRUE)
124+
try(source(tfo, local = TRUE), silent = TRUE)
119125

120126
if (length(names(e)) == 0){
121127
errmsg <- sprintf("Parsing the output of '%s' failed for an unknown reason.
@@ -210,7 +216,7 @@ readFileHeader <- function(rawfile){
210216
rawfile <- normalizePath(rawfile)
211217
.checkRawFile(rawfile)
212218

213-
e <- .rawrrSystem2Source(rawfile, input = NULL, rawrrArgs="headerR")
219+
.rawrrSystem2Source(rawfile, input = NULL, rawrrArgs="headerR") -> e
214220
e$info
215221
}
216222

0 commit comments

Comments
 (0)