Skip to content
Snippets Groups Projects
Commit 1a2577d7 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Implement cmdonly in run.run, rather than in wrappers, so e.g. $FSLDIR is

correctly prepended.
parent 1f305dc9
No related branches found
No related tags found
No related merge requests found
...@@ -151,6 +151,10 @@ def run(*args, **kwargs): ...@@ -151,6 +151,10 @@ def run(*args, **kwargs):
the :func:`.fslsub.submit` function. May also be a the :func:`.fslsub.submit` function. May also be a
dictionary containing arguments to that function. 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`` :arg log: Must be passed as a keyword argument. An optional ``dict``
which may be used to redirect the command's standard output which may be used to redirect the command's standard output
and error. The following keys are recognised: and error. The following keys are recognised:
...@@ -181,6 +185,7 @@ def run(*args, **kwargs): ...@@ -181,6 +185,7 @@ def run(*args, **kwargs):
returnStderr = kwargs.pop('stderr', False) returnStderr = kwargs.pop('stderr', False)
returnExitcode = kwargs.pop('exitcode', False) returnExitcode = kwargs.pop('exitcode', False)
submit = kwargs.pop('submit', {}) submit = kwargs.pop('submit', {})
cmdonly = kwargs.pop('cmdonly', False)
log = kwargs.pop('log', None) log = kwargs.pop('log', None)
args = prepareArgs(args) args = prepareArgs(args)
...@@ -207,6 +212,9 @@ def run(*args, **kwargs): ...@@ -207,6 +212,9 @@ def run(*args, **kwargs):
raise ValueError('submit must be a mapping containing ' raise ValueError('submit must be a mapping containing '
'options for fsl.utils.fslsub.submit') 'options for fsl.utils.fslsub.submit')
if cmdonly:
return args
if DRY_RUN: if DRY_RUN:
return _dryrun( return _dryrun(
submit, returnStdout, returnStderr, returnExitcode, *args) submit, returnStdout, returnStderr, returnExitcode, *args)
......
...@@ -172,9 +172,7 @@ def genxwrapper(func, runner): ...@@ -172,9 +172,7 @@ def genxwrapper(func, runner):
- ``exitcode``: Passed to ``runner``. Defaults to ``False``. - ``exitcode``: Passed to ``runner``. Defaults to ``False``.
- ``submit``: Passed to ``runner``. Defaults to ``None``. - ``submit``: Passed to ``runner``. Defaults to ``None``.
- ``log``: Passed to ``runner``. Defaults to ``{'tee':True}``. - ``log``: Passed to ``runner``. Defaults to ``{'tee':True}``.
- ``cmdonly``: Defaults to ``False``. If ``True``, the return - ``cmdonly``: Passed to ``runner``. Defaults to ``False``.
value of ``func`` is returned directly, instead of it being passed
to ``runner``,
:arg func: A function which generates a command line. :arg func: A function which generates a command line.
:arg runner: Either :func:`.run.run` or :func:`.run.runfsl`. :arg runner: Either :func:`.run.run` or :func:`.run.runfsl`.
...@@ -184,20 +182,19 @@ def genxwrapper(func, runner): ...@@ -184,20 +182,19 @@ def genxwrapper(func, runner):
stdout = kwargs.pop('stdout', True) stdout = kwargs.pop('stdout', True)
stderr = kwargs.pop('stderr', True) stderr = kwargs.pop('stderr', True)
exitcode = kwargs.pop('exitcode', False) exitcode = kwargs.pop('exitcode', False)
cmdonly = kwargs.pop('cmdonly', False)
submit = kwargs.pop('submit', None) submit = kwargs.pop('submit', None)
cmdonly = kwargs.pop('cmdonly', False)
log = kwargs.pop('log', {'tee' : True}) log = kwargs.pop('log', {'tee' : True})
cmd = func(*args, **kwargs) cmd = func(*args, **kwargs)
if cmdonly: return runner(cmd,
return cmd stderr=stderr,
else: log=log,
return runner(cmd, submit=submit,
stderr=stderr, cmdonly=cmdonly,
log=log, stdout=stdout,
submit=submit, exitcode=exitcode)
stdout=stdout,
exitcode=exitcode)
return _update_wrapper(wrapper, func) return _update_wrapper(wrapper, func)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment