telnet.py 文件源码

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

项目:actsys 作者: intel-ctrlsys 项目源码 文件源码
def _establish_connection(cls, remote_access_data):
        """Establish telnet connection"""
        try:
            time.sleep(cls.SLEEP_TIME)
            tnet = telnetlib.Telnet(remote_access_data.address, timeout=cls.TIMEOUT)
        except EnvironmentError:
            # print "Telnet: Error connecting to remote device"
            return None
        if remote_access_data.username != 'None':
            tnet.read_until("login:")
            tnet.write("\r\n" + remote_access_data.username + "\r\n")
        if remote_access_data.identifier != 'None':
            tnet.read_until("Password: ")
            tnet.write("\r\n" + remote_access_data.identifier + "\r\n")
            tnet.read_until(">")
        return tnet
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号