2001-03-15 01:19:35 +00:00
|
|
|
"""Handle telnet: links"""
|
2001-05-23 21:20:44 +00:00
|
|
|
# Copyright (C) 2000,2001 Bastian Kleineidam
|
2001-03-15 01:19:35 +00:00
|
|
|
#
|
2001-05-23 21:20:44 +00:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
2001-03-15 01:19:35 +00:00
|
|
|
#
|
2001-05-23 21:20:44 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2001-03-15 01:19:35 +00:00
|
|
|
#
|
2001-05-23 21:20:44 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2000-11-11 00:38:04 +00:00
|
|
|
|
2000-06-10 18:06:43 +00:00
|
|
|
import telnetlib,re,string,linkcheck
|
2000-02-26 10:24:46 +00:00
|
|
|
from HostCheckingUrlData import HostCheckingUrlData
|
2000-05-28 23:49:42 +00:00
|
|
|
from linkcheck import _
|
2000-03-21 11:38:22 +00:00
|
|
|
|
2000-04-24 22:07:48 +00:00
|
|
|
# regular expression for syntax checking
|
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"
|
2000-04-24 22:07:48 +00:00
|
|
|
|
2000-02-26 10:24:46 +00:00
|
|
|
def buildUrl(self):
|
|
|
|
|
HostCheckingUrlData.buildUrl(self)
|
2000-03-21 11:38:22 +00:00
|
|
|
if not telnet_re.match(self.urlName):
|
2000-06-10 18:06:43 +00:00
|
|
|
raise linkcheck.error, _("Illegal telnet link syntax")
|
2000-02-26 10:24:46 +00:00
|
|
|
self.host = string.lower(self.urlName[7:])
|
|
|
|
|
|
2000-11-02 10:34:22 +00:00
|
|
|
def get_scheme(self):
|
|
|
|
|
return "telnet"
|
2000-02-26 10:24:46 +00:00
|
|
|
|
|
|
|
|
def checkConnection(self, config):
|
|
|
|
|
HostCheckingUrlData.checkConnection(self, config)
|
|
|
|
|
self.urlConnection = telnetlib.Telnet()
|
|
|
|
|
self.urlConnection.open(self.host, 23)
|