Skip to content

Commit 5c49fb2

Browse files
committed
fix: ensure that commandline calls force terminal output if stdout or stderr is required
1 parent 969720e commit 5c49fb2

File tree

14 files changed

+39
-19
lines changed

14 files changed

+39
-19
lines changed

nipype/interfaces/afni/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def version():
4242
Version number as string or None if AFNI not found
4343
4444
"""
45-
clout = CommandLine(command='afni_vcheck').run()
45+
clout = CommandLine(command='afni_vcheck',
46+
terminal_output='allatonce').run()
4647
out = clout.runtime.stdout
4748
return out.split('\n')[1]
4849

@@ -87,7 +88,8 @@ def standard_image(img_name):
8788
'''Grab an image from the standard location.
8889
8990
Could be made more fancy to allow for more relocatability'''
90-
clout = CommandLine('which afni').run()
91+
clout = CommandLine('which afni',
92+
terminal_output='allatonce').run()
9193
if clout.runtime.returncode is not 0:
9294
return None
9395

nipype/interfaces/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ def __init__(self, command=None, **inputs):
11641164
if not isdefined(self.inputs.terminal_output):
11651165
self.inputs.terminal_output = self._terminal_output
11661166
else:
1167-
self._output_update()
1167+
self._terminal_output_update()
11681168

11691169
def _terminal_output_update(self):
11701170
self._terminal_output = self.inputs.terminal_output

nipype/interfaces/diffusion_toolkit/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def version():
4242
Version number as string or None if FSL not found
4343
4444
"""
45-
clout = CommandLine(command='dti_recon').run()
45+
clout = CommandLine(command='dti_recon',
46+
terminal_output='allatonce').run()
4647

4748
if clout.runtime.returncode is not 0:
4849
return None

nipype/interfaces/fsl/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def version():
7373
except KeyError:
7474
return None
7575
clout = CommandLine(command='cat',
76-
args='%s/etc/fslversion' % (basedir)).run()
76+
args='%s/etc/fslversion' % (basedir),
77+
terminal_output='allatonce').run()
7778
out = clout.runtime.stdout
7879
return out.strip('\n')
7980

nipype/interfaces/matlab.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def get_matlab_command():
1717
matlab_cmd = 'matlab'
1818

1919
try:
20-
res = CommandLine(command='which', args=matlab_cmd).run()
20+
res = CommandLine(command='which', args=matlab_cmd,
21+
terminal_output='allatonce').run()
2122
matlab_path = res.runtime.stdout.strip()
2223
except Exception, e:
2324
return None
@@ -95,6 +96,9 @@ def __init__(self, matlab_cmd = None, **inputs):
9596
not isdefined(self.inputs.uses_mcr):
9697
if config.getboolean('execution','single_thread_matlab'):
9798
self.inputs.single_comp_thread = True
99+
# For matlab commands force all output to be returned since matlab
100+
# does not have a clean way of notifying an error
101+
self.inputs.terminal_output = 'allatonce'
98102

99103
@classmethod
100104
def set_default_matlab_cmd(cls, matlab_cmd):
@@ -130,6 +134,7 @@ def set_default_paths(cls, paths):
130134
cls._default_paths = paths
131135

132136
def _run_interface(self,runtime):
137+
self.inputs.terminal_output = 'allatonce'
133138
runtime = super(MatlabCommand, self)._run_interface(runtime)
134139
try:
135140
# Matlab can leave the terminal in a barbbled state

nipype/pipeline/plugins/condor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def __init__(self, **kwargs):
4545
super(CondorPlugin, self).__init__(template, **kwargs)
4646

4747
def _is_pending(self, taskid):
48-
cmd = CommandLine('condor_q')
48+
cmd = CommandLine('condor_q',
49+
terminal_output='allatonce')
4950
cmd.inputs.args = '%d' % taskid
5051
# check condor cluster
5152
oldlevel = iflogger.level
@@ -57,7 +58,8 @@ def _is_pending(self, taskid):
5758
return False
5859

5960
def _submit_batchtask(self, scriptfile, node):
60-
cmd = CommandLine('condor_qsub', environ=os.environ.data)
61+
cmd = CommandLine('condor_qsub', environ=os.environ.data,
62+
terminal_output='allatonce')
6163
path = os.path.dirname(scriptfile)
6264
qsubargs = ''
6365
if self._qsub_args:

nipype/pipeline/plugins/dagman.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def _submit_graph(self, pyfiles, dependencies, nodes):
9595
% (' '.join([str(i) for i in parents]),
9696
child))
9797
# hand over DAG to condor_dagman
98-
cmd = CommandLine('condor_submit_dag', environ=os.environ.data)
98+
cmd = CommandLine('condor_submit_dag', environ=os.environ.data,
99+
terminal_output='allatonce')
99100
# needs -update_submit or re-running a workflow will fail
100101
cmd.inputs.args = '-update_submit %s %s' % (dagfilename,
101102
self._dagman_args)

nipype/pipeline/plugins/lsf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def _is_pending(self, taskid):
4343
and 'RUN' when it is actively being processed. But _is_pending should return True until a job has
4444
finished and is ready to be checked for completeness. So return True if status is either 'PEND'
4545
or 'RUN'"""
46-
cmd = CommandLine('bjobs')
46+
cmd = CommandLine('bjobs',
47+
terminal_output='allatonce')
4748
cmd.inputs.args = '%d' % taskid
4849
# check lsf task
4950
oldlevel = iflogger.level
@@ -57,7 +58,8 @@ def _is_pending(self, taskid):
5758
return False
5859

5960
def _submit_batchtask(self, scriptfile, node):
60-
cmd = CommandLine('bsub', environ=os.environ.data)
61+
cmd = CommandLine('bsub', environ=os.environ.data,
62+
terminal_output='allatonce')
6163
path = os.path.dirname(scriptfile)
6264
bsubargs = ''
6365
if self._bsub_args:

nipype/pipeline/plugins/pbs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def _is_pending(self, taskid):
4545
return errmsg not in e
4646

4747
def _submit_batchtask(self, scriptfile, node):
48-
cmd = CommandLine('qsub', environ=os.environ.data)
48+
cmd = CommandLine('qsub', environ=os.environ.data,
49+
terminal_output='allatonce')
4950
path = os.path.dirname(scriptfile)
5051
qsubargs = ''
5152
if self._qsub_args:

nipype/pipeline/plugins/pbsgraph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def _submit_graph(self, pyfiles, dependencies, nodes):
5353
fp.writelines('job%05d=`qsub %s %s %s`\n' % (idx, deps,
5454
qsub_args,
5555
batchscriptfile))
56-
cmd = CommandLine('sh', environ=os.environ.data)
56+
cmd = CommandLine('sh', environ=os.environ.data,
57+
terminal_output='allatonce')
5758
cmd.inputs.args = '%s' % submitjobsfile
5859
cmd.run()
5960
logger.info('submitted all jobs to queue')

0 commit comments

Comments
 (0)