Commit 12d64615 authored by Peter van 't Hof's avatar Peter van 't Hof

Added pre_command to executable check

(cherry picked from commit 0e95e90f)
parent 5f95892e
......@@ -113,7 +113,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
* Checks executable. Follow full CanonicalPath, checks if it is existing and do a md5sum on it to store in job report
*/
protected[core] def preProcessExecutable() {
val exe = BiopetCommandLineFunction.preProcessExecutable(executable)
val exe = BiopetCommandLineFunction.preProcessExecutable(executable, preCommands)
exe.path.foreach(executable = _)
addJobReportBinding("md5sum_exe", exe.md5.getOrElse("N/A"))
}
......@@ -243,13 +243,18 @@ object BiopetCommandLineFunction extends Logging {
private[core] val executableCache: mutable.Map[String, String] = mutable.Map()
case class Executable(path: Option[String], md5: Option[String])
def preProcessExecutable(executable: String): Executable = {
def preProcessExecutable(executable: String, pre_commands: List[String] = Nil): Executable = {
if (!BiopetCommandLineFunction.executableMd5Cache.contains(executable)) {
if (executable != null) {
if (!BiopetCommandLineFunction.executableCache.contains(executable)) {
try {
val buffer = new StringBuffer()
val cmd = Seq("which", executable)
val tempFile = File.createTempFile("which.", ".sh")
val writer = new PrintWriter(tempFile)
pre_commands.foreach(cmd => writer.println(cmd + " > /dev/null 2> /dev/null"))
writer.println(s"which $executable")
writer.close()
val cmd = Seq("bash", tempFile.getAbsolutePath)
val process = Process(cmd).run(ProcessLogger(buffer.append(_)))
if (process.exitValue == 0) {
val file = new File(buffer.toString)
......
Markdown is supported
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