#NEWLINE# def call_and_wait_with_input( command , input_string , wait = True , **popen_kwargs ) : #NEWLINE# #INDENT# "Run the specified command, block until it completes, and return\n    the exit code, stdout, and stderr.\n    Extends os.environment['PATH'] with the 'add_to_PATH' setting.\n    Additional parameters to Popen can be specified as keyword parameters." #NEWLINE# if subprocess . mswindows : #NEWLINE# #INDENT# startupinfo = subprocess . STARTUPINFO ( ) #NEWLINE# startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW #NEWLINE# popen_kwargs [ 'startupinfo' ] = startupinfo #NEWLINE# #UNINDENT# extended_env = get_extended_env ( ) #NEWLINE# process = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE , stdin = subprocess . PIPE , env = extended_env , ** extended_env ) #NEWLINE# if wait : #NEWLINE# #INDENT# ( stdout , stderr ) = process . communicate ( encode_bytes ( input_string ) ) #NEWLINE# exit_code = process . wait ( ) #NEWLINE# return ( exit_code , crlf2lf ( decode_bytes ( stdout ) ) , crlf2lf ( decode_bytes ( stderr ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# process . stdin . write ( encode_bytes ( input_string ) ) #NEWLINE# process . stdin . close ( ) #NEWLINE# return process