<commit_before>import re
import time

from netmiko.base_connection import BaseConnection


class FlexvnfSSH(BaseConnection):
    def session_preparation(self):
        """
        Prepare the session after the connection has been established.

        Disable paging (the '--more--' prompts).
        Set the base prompt for interaction ('>').
        """
        self._test_channel_read()
        self.enter_cli_mode()
        self.set_base_prompt()
        self.set_terminal_width(command="set screen width 511", pattern="set")
        self.disable_paging(command="set screen length 0")
        # Clear the read buffer
        time.sleep(0.3 * self.global_delay_factor)
        self.clear_buffer()

    def enter_cli_mode(self):
        """Check if at shell prompt root@ and go into CLI."""
        delay_factor = self.select_delay_factor(delay_factor=0)
        count = 0
        cur_prompt = ""
        while count < 50:
            self.write_channel(self.RETURN)
            time.sleep(0.1 * delay_factor)
            cur_prompt = self.read_channel()
            if re.search(r"admin@", cur_prompt) or re.search(
                r"^\$$", cur_prompt.strip()
            ):<commit_msg>Fix flexvnf enter cli and prompt issue (#2268)<commit_after>import re
import time

from netmiko.base_connection import BaseConnection


class FlexvnfSSH(BaseConnection):
    def session_preparation(self):
        """
        Prepare the session after the connection has been established.

        Disable paging (the '--more--' prompts).
        Set the base prompt for interaction ('>').
        """
        self._test_channel_read()
        self.enter_cli_mode()
        self.set_base_prompt()
        self.set_terminal_width(command="set screen width 511", pattern="set")
        self.disable_paging(command="set screen length 0")
        # Clear the read buffer
        time.sleep(0.3 * self.global_delay_factor)
        self.clear_buffer()

    def enter_cli_mode(self):
        """Check if at shell prompt root@ and go into CLI."""
        delay_factor = self.select_delay_factor(delay_factor=0)
        count = 0
        cur_prompt = ""
        while count < 50:
            self.write_channel(self.RETURN)
            time.sleep(0.1 * delay_factor)
            cur_prompt = self.read_channel()
            if re.search(r"admin@", cur_prompt) or re.search(
                r"\$$", cur_prompt.strip()
            ):
{'fraction_non_alphanumeric': 0.10290456431535269, 'fraction_numerical': 0.011618257261410789, 'mean_word_length': 2.348611111111111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5500874', 'n_tokens_mistral': 724, 'n_tokens_neox': 675, 'n_words': 173}