connection_debug.py 文件源码

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

项目:fermentrack 作者: thorrak 项目源码 文件源码
def test_telnet(hostname):
  # This attempts to test the validity of a controller
  # It returns a tuple (probably not the best way to do this) which is in the format:
  # Initial Connection Test (bool), Version Response Test (bool), Version Response (str)
  try:
    tn = telnetlib.Telnet(host=hostname, timeout=3)
  except socket.timeout:
    return False, False, None
  try:
    tn.write("n\r\n")
    version_string = tn.read_until("}",3)
  except:
    return True, False, None
  return True, True, version_string


# The following was used for testing during development
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号