2000-03-30 00:22:24 +00:00
|
|
|
import telnetlib,re,string
|
2000-02-26 10:24:46 +00:00
|
|
|
from HostCheckingUrlData import HostCheckingUrlData
|
2000-03-27 13:34:31 +00:00
|
|
|
from UrlData import LinkCheckerException
|
2000-03-21 11:38:22 +00:00
|
|
|
|
|
|
|
|
telnet_re = re.compile("^telnet:[\w.\-]+$")
|
2000-02-26 10:24:46 +00:00
|
|
|
|
|
|
|
|
class TelnetUrlData(HostCheckingUrlData):
|
|
|
|
|
"Url link with telnet scheme"
|
|
|
|
|
|
|
|
|
|
def buildUrl(self):
|
|
|
|
|
HostCheckingUrlData.buildUrl(self)
|
2000-03-21 11:38:22 +00:00
|
|
|
if not telnet_re.match(self.urlName):
|
2000-03-27 13:34:31 +00:00
|
|
|
raise LinkCheckerException, "Illegal telnet link syntax"
|
2000-02-26 10:24:46 +00:00
|
|
|
self.host = string.lower(self.urlName[7:])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkConnection(self, config):
|
|
|
|
|
HostCheckingUrlData.checkConnection(self, config)
|
|
|
|
|
self.urlConnection = telnetlib.Telnet()
|
|
|
|
|
self.urlConnection.open(self.host, 23)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getCacheKey(self):
|
|
|
|
|
return "telnet:"+HostCheckingUrlData.getCacheKey(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return "Telnet link\n"+HostCheckingUrlData.__str__(self)
|
|
|
|
|
|