def write_until_expected_output(self, text, expected, timeout,
                                    retry_interval, loglevel=None):
        """Writes the given text repeatedly, until `expected` appears in the output.

        `text` is written without appending a
        newline. `retry_interval` defines the time waited before
        writing `text` again. `text` is consumed from the output
        before `expected` is tried to be read.

        If `expected` does not appear in the output within `timeout`,
        this keyword fails.

        See `Read` for more information on `loglevel`.

        Example:
        | Write Until Expected Output | ps -ef| grep myprocess\\n | myprocess |
        | ...                         | 5s                        | 0.5s      |

        This writes the 'ps -ef | grep myprocess\\n', until
        'myprocess' appears on the output. The command is written
        every 0.5 seconds and the keyword ,fails if 'myprocess' does
        not appear in the output in 5 seconds.
        """
        timeout = utils.timestr_to_secs(timeout)
        retry_interval = utils.timestr_to_secs(retry_interval)
        starttime = time.time()
        while time.time() - starttime < timeout:
            self.write_bare(text)
            self.read_until(text, loglevel)
            ret = telnetlib.Telnet.read_until(self, expected,
                                              retry_interval).decode('ASCII', 'ignore')
            self._log(ret, loglevel)
            if ret.endswith(expected):
                return ret
        raise AssertionError("No match found for '%s' in %s"
                             % (expected, utils.secs_to_timestr(timeout)))
dataset/ETHPy150Open shellderp/sublime-robot-plugin/lib/robot/libraries/Telnet.py/TelnetConnection.write_until_expected_output/original