code: def check_output(params):
      
      popen = subprocess.Popen(params, shell=True, stderr=subprocess.STDOUT,
                               stdout=subprocess.PIPE)
  
      output, _ = popen.communicate()
      returncode = popen.poll()
      if returncode != 0:
          error = subprocess.CalledProcessError(returncode=returncode, cmd=params)
          error.output = output
          raise error
      return output
docs: Python 2.6 support: subprocess.check_output from Python 2.7.