def check_output(command, cwd=None, env=None, stdin=None):
stdout = subprocess.STDOUT<EOL>pipe = subprocess.PIPE<EOL>environ = os.environ.copy()<EOL>if env:<EOL><INDENT>environ.update(env)<EOL><DEDENT>with open(os.devnull) as null:<EOL><INDENT>proc = subprocess.Popen(command, cwd=cwd, env=environ, stdout=pipe, stderr=stdout, stdin=stdin or null)<EOL>output = proc.communicate()[<NUM_LIT:0>].decode('<STR_LIT:utf-8>')  <EOL><DEDENT>if proc.poll() != <NUM_LIT:0>:<EOL><INDENT>raise subprocess.CalledProcessError(proc.poll(), command, output=output)<EOL><DEDENT>return output<EOL>
Basically subprocess.check_output since it doesn't exist in Python 2.6.

    :raise CalledProcessError: Command exits non-zero.

    :param iter command: Command to run.
    :param str cwd: Current working directory.
    :param dict env: Set environment variables.
    :param file stdin: Pipe handle to subprocess' stdin.

    :return: Command output.
    :rtype: str