#NEWLINE# def check_output( * popenargs , **kwargs ) : #NEWLINE# #INDENT# 'Run command with arguments and return its output as a byte string.\n\n        If the exit code was non-zero it raises a CalledProcessError.  The\n        CalledProcessError object will have the return code in the returncode\n        attribute and output in the output attribute.\n\n        The arguments are the same as for the Popen constructor.  Example:\n\n        >>> check_output(["ls", "-l", "/dev/null"])\n        \'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\\n\'\n\n        The stdout argument is not allowed as it is used internally.\n        To capture standard error in the result, use stderr=STDOUT.\n\n        >>> check_output(["/bin/sh", "-c",\n        ...               "ls -l non_existent_file ; exit 0"],\n        ...              stderr=STDOUT)\n        \'ls: non_existent_file: No such file or directory\\n\'\n        ' #NEWLINE# if ( 'stdout' in kwargs ) : #NEWLINE# #INDENT# raise ValueError ( 'stdout argument not allowed, it will be overridden.' ) #NEWLINE# #UNINDENT# process = Popen ( * popenargs , stdout = PIPE , ** kwargs ) #NEWLINE# ( output , unused_err ) = process . communicate ( ) #NEWLINE# retcode = process . poll ( ) #NEWLINE# if retcode : #NEWLINE# #INDENT# cmd = kwargs . get ( 'args' ) #NEWLINE# if ( cmd is None ) : #NEWLINE# #INDENT# cmd = popenargs [ 0 ] #NEWLINE# #UNINDENT# error = CalledProcessError ( retcode , cmd ) #NEWLINE# error . output = output #NEWLINE# raise error #NEWLINE# #UNINDENT# return output