diff --git a/fsl/utils/run.py b/fsl/utils/run.py index 3ed799ca8330f2c17585d8959da448c3b9ccf6eb..cf75fc505ce80e7db8046133970061fdca4ead90 100644 --- a/fsl/utils/run.py +++ b/fsl/utils/run.py @@ -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) diff --git a/fsl/wrappers/wrapperutils.py b/fsl/wrappers/wrapperutils.py index 5acaeb45414318aa5879a60c976b73652626b1c2..2bfbf500c69dcef76c1e3b0a3a2de6fb8a043eb1 100644 --- a/fsl/wrappers/wrapperutils.py +++ b/fsl/wrappers/wrapperutils.py @@ -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)