From 6dcb3c86c052ae6eee6dd86dce617615bbb63863 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Tue, 9 Jan 2018 22:23:11 -0500 Subject: [PATCH 1/2] fix: logging error if % in node cmd --- nipype/pipeline/engine/nodes.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index ed1fde9d28..0749bf6b8c 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -577,25 +577,25 @@ def _run_command(self, execute, copyfiles=True): self._originputs = deepcopy(self._interface.inputs) self._copyfiles_to_wd(execute=execute) - message = '[Node] Running "%s" ("%s.%s")' + message = '[Node] Running "{}" ("{}.{}")' if issubclass(self._interface.__class__, CommandLine): try: cmd = self._interface.cmdline except Exception as msg: - result.runtime.stderr = '%s\n\n%s' % ( + result.runtime.stderr = '{}\n\n{}'.format( getattr(result.runtime, 'stderr', ''), msg) _save_resultfile(result, outdir, self.name) raise cmdfile = op.join(outdir, 'command.txt') with open(cmdfile, 'wt') as fd: print(cmd + "\n", file=fd) - message += ', a CommandLine Interface with command:\n%s' % cmd - logger.info(message, self.name, self._interface.__module__, - self._interface.__class__.__name__) + message += ', a CommandLine Interface with command:\n{}'.format(cmd) + logger.info(message.format(self.name, self._interface.__module__, + self._interface.__class__.__name__)) try: result = self._interface.run() except Exception as msg: - result.runtime.stderr = '%s\n\n%s' % ( + result.runtime.stderr = '%s\n\n%s'.format( getattr(result.runtime, 'stderr', ''), msg) _save_resultfile(result, outdir, self.name) raise From df80e446dc7e4272c13ba746c767ec73b566e034 Mon Sep 17 00:00:00 2001 From: mathiasg Date: Wed, 10 Jan 2018 11:39:56 -0500 Subject: [PATCH 2/2] fix: substitute first --- .gitignore | 1 + nipype/pipeline/engine/nodes.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 039669ce7b..69484f5a34 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ .DS_Store nipype/testing/data/von-ray_errmap.nii.gz nipype/testing/data/von_errmap.nii.gz +nipype/testing/data/.proc* crash*.pklz .coverage htmlcov/ diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index 0749bf6b8c..45b0550a47 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -577,7 +577,9 @@ def _run_command(self, execute, copyfiles=True): self._originputs = deepcopy(self._interface.inputs) self._copyfiles_to_wd(execute=execute) - message = '[Node] Running "{}" ("{}.{}")' + message = '[Node] Running "{}" ("{}.{}")'.format( + self.name, self._interface.__module__, + self._interface.__class__.__name__) if issubclass(self._interface.__class__, CommandLine): try: cmd = self._interface.cmdline @@ -590,8 +592,7 @@ def _run_command(self, execute, copyfiles=True): with open(cmdfile, 'wt') as fd: print(cmd + "\n", file=fd) message += ', a CommandLine Interface with command:\n{}'.format(cmd) - logger.info(message.format(self.name, self._interface.__module__, - self._interface.__class__.__name__)) + logger.info(message) try: result = self._interface.run() except Exception as msg: