Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
e74cdf5b
Commit
e74cdf5b
authored
Oct 05, 2015
by
Peter van 't Hof
Browse files
Improved error handeling on executable check
parent
894af898
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-core/src/main/scala/nl/lumc/sasc/biopet/core/BiopetCommandLineFunction.scala
View file @
e74cdf5b
...
...
@@ -99,37 +99,38 @@ 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
))
{
val
oldExecutable
=
executable
val
buffer
=
new
StringBuffer
()
val
cmd
=
Seq
(
"which"
,
executable
)
val
process
=
Process
(
cmd
).
run
(
ProcessLogger
(
buffer
.
append
(
_
)))
if
(
process
.
exitValue
==
0
)
{
executable
=
buffer
.
toString
val
file
=
new
File
(
executable
)
if
(
executableToCanonicalPath
)
executable
=
file
.
getCanonicalPath
else
executable
=
file
.
getAbsolutePath
}
else
{
Logging
.
addError
(
"executable: '"
+
executable
+
"' not found, please check config"
)
try
{
val
oldExecutable
=
executable
val
buffer
=
new
StringBuffer
()
val
cmd
=
Seq
(
"which"
,
executable
)
val
process
=
Process
(
cmd
).
run
(
ProcessLogger
(
buffer
.
append
(
_
)))
if
(
process
.
exitValue
==
0
)
{
executable
=
buffer
.
toString
val
file
=
new
File
(
executable
)
if
(
executableToCanonicalPath
)
executable
=
file
.
getCanonicalPath
else
executable
=
file
.
getAbsolutePath
}
else
Logging
.
addError
(
"executable: '"
+
executable
+
"' not found, please check config"
)
BiopetCommandLineFunction
.
executableCache
+=
oldExecutable
->
executable
BiopetCommandLineFunction
.
executableCache
+=
executable
->
executable
}
catch
{
case
ioe
:
java.io.IOException
=>
logger
.
warn
(
s
"Could not use 'which' on '$executable', check on executable skipped: "
+
ioe
)
}
BiopetCommandLineFunction
.
executableCache
+=
oldExecutable
->
executable
BiopetCommandLineFunction
.
executableCache
+=
executable
->
executable
}
else
{
executable
=
BiopetCommandLineFunction
.
executableCache
(
executable
)
}
}
else
executable
=
BiopetCommandLineFunction
.
executableCache
(
executable
)
if
(!
BiopetCommandLineFunction
.
executableMd5Cache
.
contains
(
executable
))
{
val
is
=
new
FileInputStream
(
executable
)
val
cnt
=
is
.
available
val
bytes
=
Array
.
ofDim
[
Byte
](
cnt
)
is
.
read
(
bytes
)
is
.
close
()
val
temp
=
MessageDigest
.
getInstance
(
"MD5"
).
digest
(
bytes
).
map
(
"%02X"
.
format
(
_
)).
mkString
.
toLowerCase
BiopetCommandLineFunction
.
executableMd5Cache
+=
executable
->
temp
if
(
new
File
(
executable
).
exists
())
{
val
is
=
new
FileInputStream
(
executable
)
val
cnt
=
is
.
available
val
bytes
=
Array
.
ofDim
[
Byte
](
cnt
)
is
.
read
(
bytes
)
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment