#NEWLINE# def _pg_run( args , env = None , stdout = PIPE ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# p = Popen ( args , env = env , stdout = stdout , stderr = STDOUT ) #NEWLINE# ( stdout , _ ) = p . communicate ( ) #NEWLINE# if ( p . returncode != 0 ) : #NEWLINE# #INDENT# raise Exception ( ( 'command failed: %s\nOUTPUT:\n%s' % ( ' ' . join ( args ) , stdout ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# except OSError as exc : #NEWLINE# #INDENT# if ( exc . errno != errno . ENOENT ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# raise Exception ( ( 'Could not find the binary %s. This is probably because\npostgresql executables are not on the path.Try setting the PATH variable\nto include the postgresql executables. On Debian Linux with PostgreSQL\nyou could run PATH=/usr/lib/postgresql/X.Y/bin:$PATH' % args [ 0 ] ) ) #NEWLINE# #UNINDENT# return stdout