utils.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:mvtest 作者: MontaVista-OpenSourceTechnology 项目源码 文件源码
def connect(self, cmd, timeout=30):
        """
        Returns:
            pexpect.spwan object: on success.

            False: on Failure

        Args:
            cmd (string): command to spawn.

            timeout (int): default 30 seconds.

        Examples:
            EX1::

                expect = ExpectShell()
                expect.connect('telnet shark 2305', timeout=60)

            Ex2::

                expect = ExpectShell()
                expect.connect('gdb a.out')
        """
        if not cmd:
            return False
        if self.shell is None:
            try:
                log.command("%s" % cmd)
                self.shell = pexpect.spawn(cmd, timeout=timeout,
                                           echo=False)
                return self.shell
            except pexpect.ExceptionPexpect:
                log.error("Failed to spwan %s " % cmd)
                return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号