remotelogin/connections/expect/expect.py
def find_expected_values_and_prompt_in_buffer(self, buff, prompt):
        """ Cycles through all the ExpectValues and check if the given value matches one of the expected values.
            Also the expected commands would contain the matched object for later retrieval

        :param str buff: buffer received via socket so far
        :param str prompt: the user prompt to remove if needed (default behavior)
        :rtype: bool

        """
        prompt_found_at_end = re.search(prompt + r"\s*$", buff, re.MULTILINE)

        self.all_matched = False
        for expect_index, expect_value in enumerate(self.expect_values):

            if expect_value.regex_object:

                if expect_value.remove_prompt_to_compare and prompt_found_at_end:
                    buff_no_prompt = buff[:prompt_found_at_end.start()]

                else:
                    buff_no_prompt = buff

                expect_value.search(buff_no_prompt)

            else:
                # we are searching for the prompt if the regex_object is empty or None
                expect_value.match_object = prompt_found_at_end

            if expect_value.match_object:

                log.debug("Found match for: " + str(expect_value))
                self.any_matched = True

                # continue next match values or return on first match

                self._matched_index_list.append(expect_index)  # to implement all_matches_in_sequence

                if not (self.all_matches_required or self.continue_matching):
                    break

        self.all_matched = all([expect_value.match_object is not None for expect_value in self.expect_values])

        if not self.all_matches_required:
            self.ok = self.any_matched
        elif not self.matches_should_be_in_sequence:
            self.ok = self.all_matched
        else:
            if self.all_matched:
                self.all_matched_in_sequence = (range(len(self.expect_values)) ==
                                                     self._matched_index_list[len(self._matched_index_list) -
                                                                              len(self.expect_values):])

            self.ok = self.all_matched_in_sequence
        return self.ok
 Cycles through all the ExpectValues and check if the given value matches one of the expected values.
            Also the expected commands would contain the matched object for later retrieval

        :param str buff: buffer received via socket so far
        :param str prompt: the user prompt to remove if needed (default behavior)
        :rtype: bool

        
Cycles through all the ExpectValues and check if the given value matches one of the expected values.
Also the expected commands would contain the matched object for later retrieval
Cycles through all the ExpectValues and check if the given value matches one of the expected values . Also the expected commands would contain the matched object for later retrieval
def find_expected_values_and_prompt_in_buffer(self, buff, prompt):
        prompt_found_at_end = re.search(prompt + r"\s*$", buff, re.MULTILINE)
        self.all_matched = False
        for expect_index, expect_value in enumerate(self.expect_values):
            if expect_value.regex_object:
                if expect_value.remove_prompt_to_compare and prompt_found_at_end:
                    buff_no_prompt = buff[:prompt_found_at_end.start()]
                else:
                    buff_no_prompt = buff
                expect_value.search(buff_no_prompt)
            else:
                expect_value.match_object = prompt_found_at_end
            if expect_value.match_object:
                log.debug("Found match for: " + str(expect_value))
                self.any_matched = True
                self._matched_index_list.append(expect_index)  
                if not (self.all_matches_required or self.continue_matching):
                    break
        self.all_matched = all([expect_value.match_object is not None for expect_value in self.expect_values])
        if not self.all_matches_required:
            self.ok = self.any_matched
        elif not self.matches_should_be_in_sequence:
            self.ok = self.all_matched
        else:
            if self.all_matched:
                self.all_matched_in_sequence = (range(len(self.expect_values)) ==
                                                     self._matched_index_list[len(self._matched_index_list) -
                                                                              len(self.expect_values):])
            self.ok = self.all_matched_in_sequence
        return self.ok
def find_expected_values_and_prompt_in_buffer ( self , buff , prompt ) : prompt_found_at_end = re . search ( prompt + r"\s*$" , buff , re . MULTILINE ) self . all_matched = False for expect_index , expect_value in enumerate ( self . expect_values ) : if expect_value . regex_object : if expect_value . remove_prompt_to_compare and prompt_found_at_end : buff_no_prompt = buff [ : prompt_found_at_end . start ( ) ] else : buff_no_prompt = buff expect_value . search ( buff_no_prompt ) else : expect_value . match_object = prompt_found_at_end if expect_value . match_object : log . debug ( "Found match for: " + str ( expect_value ) ) self . any_matched = True self . _matched_index_list . append ( expect_index ) if not ( self . all_matches_required or self . continue_matching ) : break self . all_matched = all ( [ expect_value . match_object is not None for expect_value in self . expect_values ] ) if not self . all_matches_required : self . ok = self . any_matched elif not self . matches_should_be_in_sequence : self . ok = self . all_matched else : if self . all_matched : self . all_matched_in_sequence = ( range ( len ( self . expect_values ) ) == self . _matched_index_list [ len ( self . _matched_index_list ) - len ( self . expect_values ) : ] ) self . ok = self . all_matched_in_sequence return self . ok
Cycles through all the ExpectValues and check if the given value matches one of the expected values.
Cycles through all the ExpectValues and check if the given value matches one of the expected values .
""" Cycles through all the ExpectValues and check if the given value matches one of the expected values.
            Also the expected commands would contain the matched object for later retrieval

        :param str buff: buffer received via socket so far
        :param str prompt: the user prompt to remove if needed (default behavior)
        :rtype: bool

        """ # we are searching for the prompt if the regex_object is empty or None # continue next match values or return on first match # to implement all_matches_in_sequence
None
bool
self
buff
buffer received via socket so far
buffer received via socket so far
prompt
the user prompt to remove if needed (default behavior)
the user prompt to remove if needed ( default behavior )