#NEWLINE# def run_command( args , input = None , cwd = None ) : #NEWLINE# #INDENT# popen_kwargs = dict ( stdout = subprocess . PIPE , stderr = subprocess . PIPE ) #NEWLINE# if ( p is not None ) : #NEWLINE# #INDENT# popen_kwargs [ 'cwd' ] = cwd #NEWLINE# #UNINDENT# if ( input is not None ) : #NEWLINE# #INDENT# popen_kwargs [ 'stdin' ] = subprocess . PIPE #NEWLINE# #UNINDENT# if ( os . name == 'nt' ) : #NEWLINE# #INDENT# popen_kwargs [ 'shell' ] = True #NEWLINE# #UNINDENT# p = subprocess . Popen ( args , ** popen_kwargs ) #NEWLINE# if input : #NEWLINE# #INDENT# input = encoding . smart_bytes ( input ) #NEWLINE# #UNINDENT# ( output , error ) = p . communicate ( input ) #NEWLINE# return ( encoding . smart_str ( output ) , encoding . smart_str ( error ) )