parameters: (cmd, and_stderr=False)
return_statement: return p.stdout
docstring: Return a pipe from which a command's output can be read.  cmd is the
      command.  and_stderr is set if the output should include stderr as well as
      stdout.
docstring_summary: Return a pipe from which a command's output can be read.  cmd is the
      command.  and_stderr is set if the output should include stderr as well as
      stdout.
docstring_tokens: Return a pipe from which a command s output can be read . cmd is the command . and_stderr is set if the output should include stderr as well as stdout .
function: def get_command_output(cmd, and_stderr=False):
      """ Return a pipe from which a command's output can be read.  cmd is the
      command.  and_stderr is set if the output should include stderr as well as
      stdout.
      """
  
      try:
          import subprocess
      except ImportError:
          if and_stderr:
              _, sout = os.popen4(cmd)
          else:
              _, sout, _ = os.popen3(cmd)
  
          return sout
  
      if and_stderr:
          stderr = subprocess.STDOUT
      else:
          stderr = subprocess.PIPE
  
      p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
              stdout=subprocess.PIPE, stderr=stderr)
  
      return p.stdout
function_tokens: def get_command_output ( cmd , and_stderr = False ) : try : import subprocess except ImportError : if and_stderr : _ , sout = os . popen4 ( cmd ) else : _ , sout , _ = os . popen3 ( cmd ) return sout if and_stderr : stderr = subprocess . STDOUT else : stderr = subprocess . PIPE p = subprocess . Popen ( cmd , shell = True , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = stderr ) return p . stdout