2003-07-04 14:24:44 +00:00
|
|
|
# -*- coding: iso-8859-1 -*-
|
2001-03-15 01:19:35 +00:00
|
|
|
"""Base handle for links with a hostname"""
|
2004-01-03 14:59:33 +00:00
|
|
|
# Copyright (C) 2000-2004 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
|
|
|
|
2003-01-05 21:00:32 +00:00
|
|
|
import socket, urllib
|
2000-02-26 10:24:46 +00:00
|
|
|
from UrlData import UrlData
|
2003-01-05 23:20:59 +00:00
|
|
|
from linkcheck import i18n
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2002-05-04 13:27:02 +00:00
|
|
|
class HostCheckingUrlData (UrlData):
|
2000-02-26 10:24:46 +00:00
|
|
|
"Url link for which we have to connect to a specific host"
|
|
|
|
|
|
2002-05-04 13:27:02 +00:00
|
|
|
def __init__ (self, urlName, recursionLevel, config, parentName=None,
|
2002-11-25 22:29:07 +00:00
|
|
|
baseRef=None, line=0, column=0, name=""):
|
2003-08-11 13:19:39 +00:00
|
|
|
super(HostCheckingUrlData, self).__init__(urlName, recursionLevel,
|
|
|
|
|
config, parentName=parentName, baseRef=baseRef,
|
|
|
|
|
line=line, column=column, name=name)
|
2000-02-26 10:24:46 +00:00
|
|
|
self.host = None
|
2002-12-31 00:31:22 +00:00
|
|
|
self.url = urllib.unquote(self.urlName)
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2003-07-28 12:05:24 +00:00
|
|
|
|
2002-05-04 13:27:02 +00:00
|
|
|
def buildUrl (self):
|
2000-02-26 10:24:46 +00:00
|
|
|
# to avoid anchor checking
|
2002-12-06 01:36:19 +00:00
|
|
|
self.urlparts = None
|
2001-12-10 13:51:07 +00:00
|
|
|
|
2003-07-28 12:05:24 +00:00
|
|
|
|
|
|
|
|
def getCacheKeys (self):
|
|
|
|
|
return ["%s:%s" % (self.scheme, self.host)]
|
|
|
|
|
|
2001-12-10 13:51:07 +00:00
|
|
|
|
2002-05-04 13:27:02 +00:00
|
|
|
def checkConnection (self):
|
2000-02-26 10:24:46 +00:00
|
|
|
ip = socket.gethostbyname(self.host)
|
2003-01-05 22:55:48 +00:00
|
|
|
self.setValid(self.host+"("+ip+") "+i18n._("found"))
|