def enable(
        self, cmd="enable", pattern=r"(ssword|User Name)", re_flags=re.IGNORECASE
    ):
        """Enter enable mode.
        With RADIUS can prompt for User Name
        SSH@Lab-ICX7250>en
        User Name:service_netmiko
        Password:
        SSH@Lab-ICX7250#
        """
        output = ""
        if not self.check_enable_mode():
            count = 4
            i = 1
            while i < count:
                self.write_channel(self.normalize_cmd(cmd))
                new_data = self.read_until_prompt_or_pattern(
                    pattern=pattern, re_flags=re_flags
                )
                output += new_data
                if "User Name" in new_data:
                    self.write_channel(self.normalize_cmd(self.username))
                    new_data = self.read_until_prompt_or_pattern(
                        pattern=pattern, re_flags=re_flags
                    )
                    output += new_data
                if "ssword" in new_data:
                    self.write_channel(self.normalize_cmd(self.secret))
                    output += self.read_until_prompt()
                    return output
                time.sleep(1)
                i += 1

        if not self.check_enable_mode():
            msg = (
                "Failed to enter enable mode. Please ensure you pass "
                "the 'secret' argument to ConnectHandler."
            )
            raise ValueError(msg)
def enable ( self , cmd = "enable" , pattern = r"(ssword|User Name)" , re_flags = re . IGNORECASE ) : output = "" if not self . check_enable_mode ( ) : count = 4 i = 1 while i < count : self . write_channel ( self . normalize_cmd ( cmd ) ) new_data = self . read_until_prompt_or_pattern ( pattern = pattern , re_flags = re_flags ) output += new_data if "User Name" in new_data : self . write_channel ( self . normalize_cmd ( self . username ) ) new_data = self . read_until_prompt_or_pattern ( pattern = pattern , re_flags = re_flags ) output += new_data if "ssword" in new_data : self . write_channel ( self . normalize_cmd ( self . secret ) ) output += self . read_until_prompt ( ) return output time . sleep ( 1 ) i += 1 if not self . check_enable_mode ( ) : msg = ( "Failed to enter enable mode. Please ensure you pass " "the 'secret' argument to ConnectHandler." ) raise ValueError ( msg )
Enter enable mode.
        With RADIUS can prompt for User Name
        SSH@Lab-ICX7250>en
        User Name:service_netmiko
        Password:
        SSH@Lab-ICX7250#