#NEWLINE# def execute_async( self , command ) : #NEWLINE# #INDENT# logging . debug ( "Executing command: '{}'" . format ( command . rstrip ( ) ) ) #NEWLINE# chan = self . _ssh . get_transport ( ) . open_session ( ) #NEWLINE# stdin = chan . makefile ( 'wb' ) #NEWLINE# stdout = chan . makefile ( 'rb' ) #NEWLINE# stderr = chan . makefile_stderr ( 'rb' ) #NEWLINE# cmd = ( '%s\n' % command ) #NEWLINE# if self . sudo_mode : #NEWLINE# #INDENT# cmd = ( 'sudo -S bash -c "%s"' % cmd . replace ( '"' , '\\"' ) ) #NEWLINE# chan . exec_command ( cmd ) #NEWLINE# if ( stdout . channel . closed is False ) : #NEWLINE# #INDENT# stdin . write ( ( '%s\n' % self . password ) ) #NEWLINE# stdin . flush ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# chan . exec_command ( cmd ) #NEWLINE# #UNINDENT# return ( chan , stdin , stderr , stdout )