#NEWLINE# def run_hive( args , check_return_code = True ) : #NEWLINE# #INDENT# '\n    Runs the `hive` from the command line, passing in the given args, and\n    returning stdout.\n\n    With the apache release of Hive, so of the table existence checks\n    (which are done using DESCRIBE do not exit with a return code of 0\n    so we need an option to ignore the return code and just return stdout for parsing\n    ' #NEWLINE# cmd = ( load_hive_cmd ( ) + args ) #NEWLINE# p = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# ( stdout , stderr ) = p . communicate ( ) #NEWLINE# if ( check_return_code and ( p . returncode != 0 ) ) : #NEWLINE# #INDENT# raise HiveCommandError ( 'Hive command: {0} failed with error code: {1}' . format ( ' ' . join ( cmd ) , p . returncode ) , stdout , stderr ) #NEWLINE# #UNINDENT# return stdout