执行 shell 命令并获取返回结果
        :param timeout:
        :param wait_seconds:
        :param cmd:
        :param expect_end:
        :return:

def run_expect_command(self, cmd, expect_end=None, timeout=3, wait_seconds=2):
        """
        执行 shell 命令并获取返回结果
        :param timeout:
        :param wait_seconds:
        :param cmd:
        :param expect_end:
        :return:
        """
        shell = self.ssh_session.invoke_shell()
        last_time = int(time.time())

        if not cmd.endswith('\n'):
            cmd += '\n'

        def receive():
            buff = ''
            if expect_end is None:
                buff = shell.recv(9999)
            else:
                while not buff.endswith(expect_end):
                    resp = shell.recv(9999)
                    buff += force_text(resp)
                    now = int(time.time())

                    if now - last_time > timeout:
                        break

            buff = force_text(buff)
            logger.info(buff)
            return buff

        logger.info(cmd)
        shell.send(cmd)
        time.sleep(wait_seconds)
        return receive()