Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FSL
fslpy
Commits
46b6ff71
Commit
46b6ff71
authored
7 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
New module fsl.utils.run, to replace fsl.utils.callfsl
parent
bd5bb20d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/utils/callfsl.py
+5
-0
5 additions, 0 deletions
fsl/utils/callfsl.py
fsl/utils/run.py
+71
-0
71 additions, 0 deletions
fsl/utils/run.py
with
76 additions
and
0 deletions
fsl/utils/callfsl.py
+
5
−
0
View file @
46b6ff71
...
@@ -13,12 +13,17 @@ import logging
...
@@ -13,12 +13,17 @@ import logging
import
subprocess
as
sp
import
subprocess
as
sp
import
os.path
as
op
import
os.path
as
op
import
deprecation
from
fsl.utils.platform
import
platform
as
fslplatform
from
fsl.utils.platform
import
platform
as
fslplatform
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
@deprecation.deprecated
(
deprecated_in
=
'
1.7.0
'
,
removed_in
=
'
2.0.0
'
,
details
=
'
Use fsl.utils.run.runfsl instead
'
)
def
callFSL
(
*
args
):
def
callFSL
(
*
args
):
"""
Call a FSL command and return the result.
"""
Call a FSL command and return the result.
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/run.py
0 → 100644
+
71
−
0
View file @
46b6ff71
#!/usr/bin/env python
#
# run.py - Functions for running shell commands
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
"""
This module provides some functions for running shell commands.
.. autosummary::
:nosignatures:
run
runfsl
fslsub
"""
import
logging
import
subprocess
as
sp
import
os.path
as
op
from
fsl.utils.platform
import
platform
as
fslplatform
log
=
logging
.
getLogger
(
__name__
)
def
run
(
*
args
):
"""
Call a command and return its output. You can pass the command and
arguments as a single string, or as an unpacked sequence.
"""
# If we've been given a single argument,
# assume it is a string containing the
# command and its arguments. Otherwise,
# assume it is a sequence containing
# separate command and arguments.
if
len
(
args
)
==
1
:
args
=
args
[
0
].
split
()
args
=
list
(
args
)
log
.
debug
(
'
run: {}
'
.
format
(
'
'
.
join
(
args
)))
result
=
sp
.
check_output
(
args
).
decode
(
'
utf-8
'
).
strip
()
log
.
debug
(
'
result: {}
'
.
format
(
result
))
return
result
def
runfsl
(
*
args
):
"""
Call a FSL command and return its output. This function simply prepends
$FSLDIR/bin/ to the command before passing it to :func:`run`.
"""
if
fslplatform
.
fsldir
is
None
:
raise
RuntimeError
(
'
$FSLDIR is not set - FSL cannot be found!
'
)
if
len
(
args
)
==
1
:
args
=
args
[
0
].
split
()
args
=
list
(
args
)
args
[
0
]
=
op
.
join
(
fslplatform
.
fsldir
,
'
bin
'
,
args
[
0
])
return
run
(
*
args
)
def
fslsub
(
*
args
):
"""
Not implemented yet.
"""
raise
NotImplementedError
(
''
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment