code: def Popen(cmd, stdin=None, stdout=PIPE, debug=False, shell="/bin/bash"):
      
      from subprocess import Popen as P
      if debug:
          logging.debug(cmd)
      # See: <https://blog.nelhage.com/2010/02/a-very-subtle-bug/>
      proc = P(cmd, bufsize=1, stdin=stdin, stdout=stdout, \
               shell=True, executable=shell)
      return proc
docs: Capture the cmd stdout output to a file handle.