code: def __call__(self, cmd_name, cmd, args=(), cwd=None):
      # Mqke log files
      if cmd_name in self._names:
          raise ValueError(f"Command name {cmd_name} not unique")
      self._names.append(cmd_name)
      if cwd is None:
          cwd = self.working_path
      cmd_out_path = pjoin(self.log_path, cmd_name)
      stdout_log = open(cmd_out_path + ".stdout", "w")
      stderr_log = open(cmd_out_path + ".stderr", "w")
      try:
          # Start subprocess
          cmd_str = self.cmd_str_maker(cmd, args)
          proc = Popen(
              cmd_str,
              cwd=cwd,
              stdout=stdout_log,
              stderr=stderr_log,
              shell=NEED_SHELL,
          )
          # Execute
          retcode = proc.wait()
      finally:
          if proc.poll() is None:  # In case we get killed
              proc.terminate()
          stdout_log.close()
          stderr_log.close()
      return retcode
  
file_path: nipy/tools/run_log_examples.py
imports: import os
  import re
  import sys
  from argparse import ArgumentParser, RawDescriptionHelpFormatter
  from os.path import abspath, dirname, expanduser, isfile
  from os.path import join
  from os.path import sep
  from subprocess import PIPE, Popen
label_desc: Use image node_id 3 for calling the ProcLogger obj's underlying member method code with example usage: obj.__call__(cmd_name, cmd, args, cwd) and returns: retcode