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
genotoul-bioinfo
jflow
Commits
1ccfe803
Commit
1ccfe803
authored
Oct 23, 2013
by
Jerome Mariette
Browse files
better handle of makeflow path checking
parent
95173205
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/jflow/component.py
View file @
1ccfe803
...
...
@@ -16,12 +16,14 @@
#
import
os
import
sys
import
inspect
import
tempfile
from
jflow.workflows_manager
import
WorkflowsManager
from
jflow.config_reader
import
JFlowConfigReader
from
jflow.dataset
import
ArrayList
from
jflow.utils
import
which
from
weaver.util
import
parse_string_list
...
...
@@ -131,7 +133,16 @@ class Component(object):
return
self
.
config_reader
.
get_resource
(
resource
)
def
get_exec_path
(
self
,
software
):
return
self
.
config_reader
.
get_exec
(
software
)
exec_path
=
self
.
config_reader
.
get_exec
(
software
)
if
exec_path
is
None
and
os
.
path
.
isfile
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"../bin"
,
software
)):
exec_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"../bin"
,
software
)
elif
exec_path
is
None
and
os
.
path
.
isfile
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"bin"
,
software
)):
exec_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"bin"
,
software
)
if
exec_path
is
None
:
exec_path
=
software
if
which
(
exec_path
)
==
None
:
sys
.
stderr
.
write
(
"Error: '"
+
software
+
"' path connot be retrieved either in the PATH and in the application.properties file!
\n
"
)
sys
.
exit
(
1
)
return
exec_path
def
get_nameid
(
self
):
return
self
.
__class__
.
__name__
+
"."
+
self
.
prefix
...
...
src/jflow/config_reader.py
View file @
1ccfe803
...
...
@@ -20,7 +20,9 @@ import sys
import
inspect
from
ConfigParser
import
ConfigParser
,
NoOptionError
from
jflow.utils
import
which
class
JFlowConfigReader
(
object
):
"""
...
...
@@ -34,25 +36,6 @@ class JFlowConfigReader(object):
self
.
reader
=
ConfigParser
()
self
.
reader
.
read
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
self
.
CONFIG_FILE_PATH
))
def
__which
(
self
,
program
):
"""
Return if the asked program exist in the user path
@param options : the options asked by the user
"""
import
os
def
is_exe
(
fpath
):
return
os
.
path
.
exists
(
fpath
)
and
os
.
access
(
fpath
,
os
.
X_OK
)
fpath
,
fname
=
os
.
path
.
split
(
program
)
if
fpath
:
if
is_exe
(
program
):
return
program
else
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
exe_file
=
os
.
path
.
join
(
path
,
program
)
if
is_exe
(
exe_file
):
return
exe_file
return
None
def
get_tmp_directory
(
self
):
return
self
.
reader
.
get
(
"storage"
,
"tmp_directory"
)
...
...
@@ -61,18 +44,9 @@ class JFlowConfigReader(object):
def
get_exec
(
self
,
software
):
try
:
exec_path
=
self
.
reader
.
get
(
"softwares"
,
software
)
return
self
.
reader
.
get
(
"softwares"
,
software
)
except
NoOptionError
,
e
:
exec_path
=
None
if
exec_path
is
None
and
os
.
path
.
isfile
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"../bin"
,
software
)):
exec_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"../bin"
,
software
)
elif
exec_path
is
None
and
os
.
path
.
isfile
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"bin"
,
software
)):
exec_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"bin"
,
software
)
if
exec_path
is
None
:
exec_path
=
software
if
self
.
__which
(
exec_path
)
==
None
:
sys
.
stderr
.
write
(
"Error: '"
+
software
+
"' path connot be retrieved either in the PATH and in the application.properties file!
\n
"
)
sys
.
exit
(
1
)
return
exec_path
return
None
def
get_resource
(
self
,
resource
):
return
self
.
reader
.
get
(
"resources"
,
resource
)
...
...
@@ -93,7 +67,7 @@ class JFlowConfigReader(object):
except
NoOptionError
,
e
:
exec_path
=
None
if
exec_path
is
None
:
exec_path
=
software
if
self
.
__
which
(
exec_path
)
==
None
:
if
which
(
exec_path
)
==
None
:
sys
.
stderr
.
write
(
"Error: 'makeflow' path connot be retrieved either in the PATH and in the application.properties file!
\n
"
)
sys
.
exit
(
1
)
return
exec_path
...
...
src/jflow/utils.py
View file @
1ccfe803
...
...
@@ -15,6 +15,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
def
which
(
program
):
"""
Return if the asked program exist in the user path
@param options : the options asked by the user
"""
import
os
def
is_exe
(
fpath
):
return
os
.
path
.
exists
(
fpath
)
and
os
.
access
(
fpath
,
os
.
X_OK
)
fpath
,
fname
=
os
.
path
.
split
(
program
)
if
fpath
:
if
is_exe
(
program
):
return
program
else
:
for
path
in
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
):
exe_file
=
os
.
path
.
join
(
path
,
program
)
if
is_exe
(
exe_file
):
return
exe_file
return
None
def
get_file_base
(
file
):
"""
Return the file base
...
...
src/jflow/workflow.py
View file @
1ccfe803
...
...
@@ -179,7 +179,16 @@ class Workflow(threading.Thread):
return
[
parameters
,
parameters_order
]
def
get_exec_path
(
self
,
software
):
return
self
.
jflow_config_reader
.
get_exec
(
software
)
exec_path
=
self
.
jflow_config_reader
.
get_exec
(
software
)
if
exec_path
is
None
and
os
.
path
.
isfile
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"../bin"
,
software
)):
exec_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"../bin"
,
software
)
elif
exec_path
is
None
and
os
.
path
.
isfile
(
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"bin"
,
software
)):
exec_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
inspect
.
getfile
(
self
.
__class__
)),
"bin"
,
software
)
if
exec_path
is
None
:
exec_path
=
software
if
utils
.
which
(
exec_path
)
==
None
:
sys
.
stderr
.
write
(
"Error: '"
+
software
+
"' path connot be retrieved either in the PATH and in the application.properties file!
\n
"
)
sys
.
exit
(
1
)
return
exec_path
def
add_component
(
self
,
component_name
,
args
=
[],
kwargs
=
{},
component_prefix
=
"default"
):
# first build and check if this component is OK
...
...
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