code: def stream(command, stdin=None, env=os.environ, timeout=None):
      
      if not isinstance(command, list):
          command = shlex.split(command)
  
      cmd = which(command[0])
      if cmd is None:
          path = env.get("PATH", "")
          raise Exception("Command [%s] not in PATH [%s]" % (command[0], path))
  
      command[0] = cmd
  
      if timeout:
          if not timeout_command[0]:
              raise Exception("Timeout specified but timeout command not available.")
          command = timeout_command + [str(timeout)] + command
  
      output = None
      try:
          output = Popen(command, env=env, stdin=stdin, **stream_options)
          yield output.stdout
      finally:
          if output:
              output.wait()
docs: Yields a generator of a command's output. For line oriented commands only.
  
      Args:
          command (str or list): a command without pipes. If it's not a list,
              ``shlex.split`` is applied.
          stdin (file like object): stream to use as the command's standard input.
          env (dict): The environment in which to execute the command. PATH should
              be defined.
          timeout (int): Amount of time in seconds to give the command to complete.
              The ``timeout`` utility must be installed to use this feature.
  
      Yields:
          The output stream for the command. It should typically be wrapped in a
          ``reader``.