Commit e74cdf5b authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Improved error handeling on executable check

parent 894af898
......@@ -99,8 +99,9 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
*/
protected[core] def preProcessExecutable() {
if (!BiopetCommandLineFunction.executableMd5Cache.contains(executable)) {
try if (executable != null) {
if (executable != null) {
if (!BiopetCommandLineFunction.executableCache.contains(executable)) {
try {
val oldExecutable = executable
val buffer = new StringBuffer()
val cmd = Seq("which", executable)
......@@ -110,16 +111,17 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
val file = new File(executable)
if (executableToCanonicalPath) executable = file.getCanonicalPath
else executable = file.getAbsolutePath
} else {
Logging.addError("executable: '" + executable + "' not found, please check config")
}
} else Logging.addError("executable: '" + executable + "' not found, please check config")
BiopetCommandLineFunction.executableCache += oldExecutable -> executable
BiopetCommandLineFunction.executableCache += executable -> executable
} else {
executable = BiopetCommandLineFunction.executableCache(executable)
} catch {
case ioe: java.io.IOException =>
logger.warn(s"Could not use 'which' on '$executable', check on executable skipped: " + ioe)
}
} else executable = BiopetCommandLineFunction.executableCache(executable)
if (!BiopetCommandLineFunction.executableMd5Cache.contains(executable)) {
if (new File(executable).exists()) {
val is = new FileInputStream(executable)
val cnt = is.available
val bytes = Array.ofDim[Byte](cnt)
......@@ -127,9 +129,8 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
is.close()
val temp = MessageDigest.getInstance("MD5").digest(bytes).map("%02X".format(_)).mkString.toLowerCase
BiopetCommandLineFunction.executableMd5Cache += executable -> temp
} else BiopetCommandLineFunction.executableMd5Cache += executable -> "file_does_not_exist"
}
} catch {
case ioe: java.io.IOException => logger.warn("Could not use 'which', check on executable skipped: " + ioe)
}
}
val md5 = BiopetCommandLineFunction.executableMd5Cache.get(executable)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment