Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Arthofer
fslpy
Commits
1a2577d7
Commit
1a2577d7
authored
Oct 12, 2020
by
Paul McCarthy
🚵
Browse files
RF: Implement cmdonly in run.run, rather than in wrappers, so e.g. $FSLDIR is
correctly prepended.
parent
1f305dc9
Changes
2
Hide whitespace changes
Inline
Side-by-side
fsl/utils/run.py
View file @
1a2577d7
...
...
@@ -151,6 +151,10 @@ def run(*args, **kwargs):
the :func:`.fslsub.submit` function. May also be a
dictionary containing arguments to that function.
:arg cmdonly: Defaults to ``False``. If ``True``, the command is not
executed, but rather is returned directly, as a list of
arguments.
:arg log: Must be passed as a keyword argument. An optional ``dict``
which may be used to redirect the command's standard output
and error. The following keys are recognised:
...
...
@@ -181,6 +185,7 @@ def run(*args, **kwargs):
returnStderr
=
kwargs
.
pop
(
'stderr'
,
False
)
returnExitcode
=
kwargs
.
pop
(
'exitcode'
,
False
)
submit
=
kwargs
.
pop
(
'submit'
,
{})
cmdonly
=
kwargs
.
pop
(
'cmdonly'
,
False
)
log
=
kwargs
.
pop
(
'log'
,
None
)
args
=
prepareArgs
(
args
)
...
...
@@ -207,6 +212,9 @@ def run(*args, **kwargs):
raise
ValueError
(
'submit must be a mapping containing '
'options for fsl.utils.fslsub.submit'
)
if
cmdonly
:
return
args
if
DRY_RUN
:
return
_dryrun
(
submit
,
returnStdout
,
returnStderr
,
returnExitcode
,
*
args
)
...
...
fsl/wrappers/wrapperutils.py
View file @
1a2577d7
...
...
@@ -172,9 +172,7 @@ def genxwrapper(func, runner):
- ``exitcode``: Passed to ``runner``. Defaults to ``False``.
- ``submit``: Passed to ``runner``. Defaults to ``None``.
- ``log``: Passed to ``runner``. Defaults to ``{'tee':True}``.
- ``cmdonly``: Defaults to ``False``. If ``True``, the return
value of ``func`` is returned directly, instead of it being passed
to ``runner``,
- ``cmdonly``: Passed to ``runner``. Defaults to ``False``.
:arg func: A function which generates a command line.
:arg runner: Either :func:`.run.run` or :func:`.run.runfsl`.
...
...
@@ -184,20 +182,19 @@ def genxwrapper(func, runner):
stdout
=
kwargs
.
pop
(
'stdout'
,
True
)
stderr
=
kwargs
.
pop
(
'stderr'
,
True
)
exitcode
=
kwargs
.
pop
(
'exitcode'
,
False
)
cmdonly
=
kwargs
.
pop
(
'cmdonly'
,
False
)
submit
=
kwargs
.
pop
(
'submit'
,
None
)
cmdonly
=
kwargs
.
pop
(
'cmdonly'
,
False
)
log
=
kwargs
.
pop
(
'log'
,
{
'tee'
:
True
})
cmd
=
func
(
*
args
,
**
kwargs
)
if
cmdonly
:
return
cmd
else
:
return
runner
(
cmd
,
stderr
=
stderr
,
log
=
log
,
submit
=
submit
,
stdout
=
stdout
,
exitcode
=
exitcode
)
return
runner
(
cmd
,
stderr
=
stderr
,
log
=
log
,
submit
=
submit
,
cmdonly
=
cmdonly
,
stdout
=
stdout
,
exitcode
=
exitcode
)
return
_update_wrapper
(
wrapper
,
func
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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