remotelogin/connections/terminal/__init__.py
def expect_ask_response_list(
        self,
        ask_response_list,
        stop_after_getting=None,
        timeout_after_first_match=0,
        remove_prompt_to_compare=True,
        chain=False,
        **kwargs
    ):
        """ simple procedure to go through a list of expected values and their corresponding responses

            There are some conditions that might break the required statement on some of the items in the list:
                - if there is an item with response=None we suspect is the prompt and we break
                - if stop_after_getting is set and we match a name in it we break

        Args:
            ask_response_list (list of dict or list of term.ExpectAndResponse):
            stop_after_getting (str): name of ExpectAndResponse object that if matched would trigger returning
            remove_prompt_to_compare (bool): whether we want to remove prompt to compare all the expects
            chain (bool): whether to return self (chain=True) or return the dictionary of results
            timeout_after_first_match (int): timeout to assign to all the expects after first match
            **kwargs (dict): default parameters for each expect

        Returns:

        """

        # separate values with names from those without name and also add an index to each
        expect_list, ask_resp_list_by_name = create_expectedregex_objects(
            ask_response_list, kwargs, remove_prompt_to_compare
        )

        stop_after_getting = fdutils.lists.to_sequence(stop_after_getting)

        i = 0
        match_set = set()
        match_list = {}
        _kwargs = kwargs

        while len(expect_list):
            exp = self.expect(*expect_list.values(), **kwargs)

            quota_filled, continue_checking = ask_resp_list_by_name[
                exp.name
            ].match_found()

            if quota_filled:
                match_set.add(exp.name)
                match_list[exp.name] = expect_list[exp.name]

            if not continue_checking:
                del expect_list[exp.name]

            if ask_resp_list_by_name[exp.name].response is not None:
                self.send_cmd(
                    ask_resp_list_by_name[exp.name].response,
                    is_hidden=ask_resp_list_by_name[exp.name].hidden,
                )
            else:  # implicit prompt
                break

            any_required_left = any(
                ask_resp_list_by_name[l].required for l in expect_list
            )

            if (
                stop_after_getting
                and exp.name in stop_after_getting
                or not any_required_left
            ):
                break

            kwargs = ask_resp_list_by_name[exp.name].kwargs or _kwargs

            # change timeout for next expect
            if timeout_after_first_match:
                kwargs["timeout"] = timeout_after_first_match

            i += 1

        if chain:
            return self
        else:
            return match_list
 simple procedure to go through a list of expected values and their corresponding responses

            There are some conditions that might break the required statement on some of the items in the list:
                - if there is an item with response=None we suspect is the prompt and we break
                - if stop_after_getting is set and we match a name in it we break

        Args:
            ask_response_list (list of dict or list of term.ExpectAndResponse):
            stop_after_getting (str): name of ExpectAndResponse object that if matched would trigger returning
            remove_prompt_to_compare (bool): whether we want to remove prompt to compare all the expects
            chain (bool): whether to return self (chain=True) or return the dictionary of results
            timeout_after_first_match (int): timeout to assign to all the expects after first match
            **kwargs (dict): default parameters for each expect

        Returns:

        
simple procedure to go through a list of expected values and their corresponding responses
There are some conditions that might break the required statement on some of the items in the list:
if there is an item with response=None we suspect is the prompt and we break
if stop_after_getting is set and we match a name in it we break
simple procedure to go through a list of expected values and their corresponding responses There are some conditions that might break the required statement on some of the items in the list : if there is an item with response = None we suspect is the prompt and we break if stop_after_getting is set and we match a name in it we break
def expect_ask_response_list(
        self,
        ask_response_list,
        stop_after_getting=None,
        timeout_after_first_match=0,
        remove_prompt_to_compare=True,
        chain=False,
        **kwargs
    ):
        expect_list, ask_resp_list_by_name = create_expectedregex_objects(
            ask_response_list, kwargs, remove_prompt_to_compare
        )
        stop_after_getting = fdutils.lists.to_sequence(stop_after_getting)
        i = 0
        match_set = set()
        match_list = {}
        _kwargs = kwargs
        while len(expect_list):
            exp = self.expect(*expect_list.values(), **kwargs)
            quota_filled, continue_checking = ask_resp_list_by_name[
                exp.name
            ].match_found()
            if quota_filled:
                match_set.add(exp.name)
                match_list[exp.name] = expect_list[exp.name]
            if not continue_checking:
                del expect_list[exp.name]
            if ask_resp_list_by_name[exp.name].response is not None:
                self.send_cmd(
                    ask_resp_list_by_name[exp.name].response,
                    is_hidden=ask_resp_list_by_name[exp.name].hidden,
                )
            else:  
                break
            any_required_left = any(
                ask_resp_list_by_name[l].required for l in expect_list
            )
            if (
                stop_after_getting
                and exp.name in stop_after_getting
                or not any_required_left
            ):
                break
            kwargs = ask_resp_list_by_name[exp.name].kwargs or _kwargs
            if timeout_after_first_match:
                kwargs["timeout"] = timeout_after_first_match
            i += 1
        if chain:
            return self
        else:
            return match_list
def expect_ask_response_list ( self , ask_response_list , stop_after_getting = None , timeout_after_first_match = 0 , remove_prompt_to_compare = True , chain = False , ** kwargs ) : expect_list , ask_resp_list_by_name = create_expectedregex_objects ( ask_response_list , kwargs , remove_prompt_to_compare ) stop_after_getting = fdutils . lists . to_sequence ( stop_after_getting ) i = 0 match_set = set ( ) match_list = { } _kwargs = kwargs while len ( expect_list ) : exp = self . expect ( * expect_list . values ( ) , ** kwargs ) quota_filled , continue_checking = ask_resp_list_by_name [ exp . name ] . match_found ( ) if quota_filled : match_set . add ( exp . name ) match_list [ exp . name ] = expect_list [ exp . name ] if not continue_checking : del expect_list [ exp . name ] if ask_resp_list_by_name [ exp . name ] . response is not None : self . send_cmd ( ask_resp_list_by_name [ exp . name ] . response , is_hidden = ask_resp_list_by_name [ exp . name ] . hidden , ) else : break any_required_left = any ( ask_resp_list_by_name [ l ] . required for l in expect_list ) if ( stop_after_getting and exp . name in stop_after_getting or not any_required_left ) : break kwargs = ask_resp_list_by_name [ exp . name ] . kwargs or _kwargs if timeout_after_first_match : kwargs [ "timeout" ] = timeout_after_first_match i += 1 if chain : return self else : return match_list
simple procedure to go through a list of expected values and their corresponding responses
There are some conditions that might break the required statement on some of the items in the list:
 if there is an item with response=None we suspect is the prompt and we break
 if stop_after_getting is set and we match a name in it we break
simple procedure to go through a list of expected values and their corresponding responses There are some conditions that might break the required statement on some of the items in the list : if there is an item with response = None we suspect is the prompt and we break if stop_after_getting is set and we match a name in it we break
""" simple procedure to go through a list of expected values and their corresponding responses

            There are some conditions that might break the required statement on some of the items in the list:
                - if there is an item with response=None we suspect is the prompt and we break
                - if stop_after_getting is set and we match a name in it we break

        Args:
            ask_response_list (list of dict or list of term.ExpectAndResponse):
            stop_after_getting (str): name of ExpectAndResponse object that if matched would trigger returning
            remove_prompt_to_compare (bool): whether we want to remove prompt to compare all the expects
            chain (bool): whether to return self (chain=True) or return the dictionary of results
            timeout_after_first_match (int): timeout to assign to all the expects after first match
            **kwargs (dict): default parameters for each expect

        Returns:

        """ # separate values with names from those without name and also add an index to each # implicit prompt # change timeout for next expect
None
self
ask_response_list
None
stop_after_getting
name of ExpectAndResponse object that if matched would trigger returning
name of ExpectAndResponse object that if matched would trigger returning
timeout_after_first_match
timeout to assign to all the expects after first match
timeout to assign to all the expects after first match
remove_prompt_to_compare
whether we want to remove prompt to compare all the expects
whether we want to remove prompt to compare all the expects
chain
whether to return self (chain=True) or return the dictionary of results
whether to return self ( chain = True ) or return the dictionary of results
**kwargs
default parameters for each expect
default parameters for each expect