Skip to content
Snippets Groups Projects
Commit fe70b7cc authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

getVersion now also use stderr, also log output when version command is failed

parent 54339295
No related branches found
No related tags found
No related merge requests found
...@@ -83,20 +83,21 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab ...@@ -83,20 +83,21 @@ trait BiopetCommandLineFunctionTrait extends CommandLineFunction with Configurab
protected val versionExitcode = List(0) // Can select multiple protected val versionExitcode = List(0) // Can select multiple
def getVersion: String = { def getVersion: String = {
if (versionCommand == null || versionRegex == null) return "N/A" if (versionCommand == null || versionRegex == null) return "N/A"
val buffer = new StringBuffer() val stdout = new StringBuffer()
val process = Process(versionCommand).run(ProcessLogger(buffer append _)) val stderr = new StringBuffer()
def outputLog = "\n output log: \n stdout: \n" + stdout.toString + "\n stderr: \n" + stderr.toString
val process = Process(versionCommand).run(ProcessLogger(stdout append _, stderr append _))
if (!versionExitcode.contains(process.exitValue)) { if (!versionExitcode.contains(process.exitValue)) {
logger.warn("Version command: '" + versionCommand + "' give exit code " + process.exitValue + ", version not found") logger.warn("Version command: '" + versionCommand + "' give exit code " + process.exitValue + ", version not found" + outputLog)
return "N/A" return "N/A"
} }
val lines = versionCommand lines_! ProcessLogger(buffer append _) for (line <- stdout.toString.split("\n") ++ stderr.toString.split("\n")) {
for (line <- lines) {
line match { line match {
case versionRegex(m) => return m case versionRegex(m) => return m
case _ => case _ =>
} }
} }
logger.warn("Version command: '" + versionCommand + "' give a exit code " + process.exitValue + " but no version was found, executable oke?") logger.warn("Version command: '" + versionCommand + "' give a exit code " + process.exitValue + " but no version was found, executable correct?" + outputLog)
return "N/A" return "N/A"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment