remotelogin/connections/terminal/__init__.py
def _get_banner_and_prompt(self, terminal, previous_prompt=None):
        """ Get information about a new login (message of the day and prompt).

        It cycles reading a socket until it times out to automatically retrieve the banner message (motd) and the prompt.
        If given the expected_prompt, we will only wait until we get expected_prompt or login_timeout whoever is first

        """

        # send a new line
        self.send_line(force_flush=True, flush_timeout=settings.FLUSH_RECV_TIMEOUT * 2)
        data_received, prompt_timer_expired, prompt_found = self._find_prompt(
            terminal, terminal.shell.expected_prompt
        )

        if not data_received:
            raise exceptions.ExpectLoginError(
                "Did not get any banner message or prompt???"
            )

        data_received_lines = data_received.splitlines()
        prompt = re.escape(
            (prompt_found or self.__get_last_line_prompt(data_received_lines)).rstrip(
                "\n"
            )
        )
        banner = data_received[: data_received.find(prompt) or len(data_received)]

        if (
            previous_prompt
            and prompt == previous_prompt
            and self.check_same_prompt_when_opening_terminal
            and (
                not terminal.shell.expected_prompt
                or terminal.shell.expected_prompt != prompt
            )
            and not terminal.shell.skip_prompt_check
            and (
                not len(self._terminals) or self._terminals[-1].shell.can_change_prompt
            )
        ):
            raise exceptions.ExpectLoginError(
                "The prompt is still the same ({}). "
                "We might have not logged into anywhere".format(previous_prompt)
            )

        elif (
            not self.allow_non_expected_prompt
            and terminal.shell.expected_prompt
            and prompt_timer_expired
        ):
            raise exceptions.ExpectLoginError(
                "The expected prompt {} is different to the one we got {} . "
                "We might be in the wrong place or the expected prompt is wrong"
                "".format(terminal.shell.expected_prompt, prompt)
            )
        else:
            if prompt_timer_expired and terminal.shell.expected_prompt:
                log.info(
                    "Prompt {} different to expected {} and . You might need to update it"
                    "".format(terminal.shell.expected_prompt, prompt)
                )

            return banner, prompt
 Get information about a new login (message of the day and prompt).

        It cycles reading a socket until it times out to automatically retrieve the banner message (motd) and the prompt.
        If given the expected_prompt, we will only wait until we get expected_prompt or login_timeout whoever is first

        
Get information about a new login (message of the day and prompt).
It cycles reading a socket until it times out to automatically retrieve the banner message (motd) and the prompt.
If given the expected_prompt, we will only wait until we get expected_prompt or login_timeout whoever is first
Get information about a new login ( message of the day and prompt ) . It cycles reading a socket until it times out to automatically retrieve the banner message ( motd ) and the prompt . If given the expected_prompt we will only wait until we get expected_prompt or login_timeout whoever is first
def _get_banner_and_prompt(self, terminal, previous_prompt=None):
        self.send_line(force_flush=True, flush_timeout=settings.FLUSH_RECV_TIMEOUT * 2)
        data_received, prompt_timer_expired, prompt_found = self._find_prompt(
            terminal, terminal.shell.expected_prompt
        )
        if not data_received:
            raise exceptions.ExpectLoginError(
                "Did not get any banner message or prompt???"
            )
        data_received_lines = data_received.splitlines()
        prompt = re.escape(
            (prompt_found or self.__get_last_line_prompt(data_received_lines)).rstrip(
                "\n"
            )
        )
        banner = data_received[: data_received.find(prompt) or len(data_received)]
        if (
            previous_prompt
            and prompt == previous_prompt
            and self.check_same_prompt_when_opening_terminal
            and (
                not terminal.shell.expected_prompt
                or terminal.shell.expected_prompt != prompt
            )
            and not terminal.shell.skip_prompt_check
            and (
                not len(self._terminals) or self._terminals[-1].shell.can_change_prompt
            )
        ):
            raise exceptions.ExpectLoginError(
                "The prompt is still the same ({}). "
                "We might have not logged into anywhere".format(previous_prompt)
            )
        elif (
            not self.allow_non_expected_prompt
            and terminal.shell.expected_prompt
            and prompt_timer_expired
        ):
            raise exceptions.ExpectLoginError(
                "The expected prompt {} is different to the one we got {} . "
                "We might be in the wrong place or the expected prompt is wrong"
                "".format(terminal.shell.expected_prompt, prompt)
            )
        else:
            if prompt_timer_expired and terminal.shell.expected_prompt:
                log.info(
                    "Prompt {} different to expected {} and . You might need to update it"
                    "".format(terminal.shell.expected_prompt, prompt)
                )
            return banner, prompt
def _get_banner_and_prompt ( self , terminal , previous_prompt = None ) : self . send_line ( force_flush = True , flush_timeout = settings . FLUSH_RECV_TIMEOUT * 2 ) data_received , prompt_timer_expired , prompt_found = self . _find_prompt ( terminal , terminal . shell . expected_prompt ) if not data_received : raise exceptions . ExpectLoginError ( "Did not get any banner message or prompt???" ) data_received_lines = data_received . splitlines ( ) prompt = re . escape ( ( prompt_found or self . __get_last_line_prompt ( data_received_lines ) ) . rstrip ( "\n" ) ) banner = data_received [ : data_received . find ( prompt ) or len ( data_received ) ] if ( previous_prompt and prompt == previous_prompt and self . check_same_prompt_when_opening_terminal and ( not terminal . shell . expected_prompt or terminal . shell . expected_prompt != prompt ) and not terminal . shell . skip_prompt_check and ( not len ( self . _terminals ) or self . _terminals [ - 1 ] . shell . can_change_prompt ) ) : raise exceptions . ExpectLoginError ( "The prompt is still the same ({}). " "We might have not logged into anywhere" . format ( previous_prompt ) ) elif ( not self . allow_non_expected_prompt and terminal . shell . expected_prompt and prompt_timer_expired ) : raise exceptions . ExpectLoginError ( "The expected prompt {} is different to the one we got {} . " "We might be in the wrong place or the expected prompt is wrong" "" . format ( terminal . shell . expected_prompt , prompt ) ) else : if prompt_timer_expired and terminal . shell . expected_prompt : log . info ( "Prompt {} different to expected {} and . You might need to update it" "" . format ( terminal . shell . expected_prompt , prompt ) ) return banner , prompt
Get information about a new login (message of the day and prompt).
Get information about a new login ( message of the day and prompt ) .
""" Get information about a new login (message of the day and prompt).

        It cycles reading a socket until it times out to automatically retrieve the banner message (motd) and the prompt.
        If given the expected_prompt, we will only wait until we get expected_prompt or login_timeout whoever is first

        """ # send a new line
self
terminal
previous_prompt