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
评论列表
文章目录