#NEWLINE# def enable( self , cmd = 'sudo su' , pattern = 'ssword' , re_flags = re . IGNORECASE ) : #NEWLINE# #INDENT# 'Attempt to become root.' #NEWLINE# output = '' #NEWLINE# if ( not self . check_enable_mode ( ) ) : #NEWLINE# #INDENT# self . remote_conn . sendall ( self . normalize_cmd ( cmd ) ) #NEWLINE# pattern = re . escape ( pattern ) #NEWLINE# base_prompt_pattern = re . escape ( self . base_prompt ) #NEWLINE# output = '' #NEWLINE# try : #NEWLINE# #INDENT# output += self . remote_conn . recv ( MAX_BUFFER ) . decode ( 'utf-8' , 'ignore' ) #NEWLINE# if re . search ( pattern , output , flags = re_flags ) : #NEWLINE# #INDENT# self . remote_conn . sendall ( self . normalize_cmd ( self . secret ) ) #NEWLINE# #UNINDENT# self . set_base_prompt ( ) #NEWLINE# #UNINDENT# except socket . timeout : #NEWLINE# #INDENT# raise NetMikoTimeoutException ( 'Timed-out reading channel, data not available.' ) #NEWLINE# #UNINDENT# if ( not self . check_enable_mode ( ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Failed to enter enable mode.' ) #NEWLINE# #UNINDENT# #UNINDENT# return output