2001-03-15 01:19:35 +00:00
|
|
|
"""main function module for link checking"""
|
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-04-10 16:58:05 +00:00
|
|
|
|
2000-06-10 18:06:43 +00:00
|
|
|
class error(Exception):
|
|
|
|
|
pass
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2000-04-30 22:34:43 +00:00
|
|
|
# i18n suppport
|
2000-12-22 16:25:32 +00:00
|
|
|
LANG="EN" # default language (used for HTML output)
|
2001-04-13 11:39:21 +00:00
|
|
|
import _linkchecker_configdata
|
2000-04-30 22:34:43 +00:00
|
|
|
try:
|
2000-12-22 16:25:32 +00:00
|
|
|
import fintl,os,string
|
2000-11-09 12:02:38 +00:00
|
|
|
gettext = fintl.gettext
|
2000-05-22 12:00:54 +00:00
|
|
|
domain = 'linkcheck'
|
2001-04-13 11:39:21 +00:00
|
|
|
localedir = os.path.join(_linkchecker_configdata.install_data, 'locale')
|
2000-11-09 12:02:38 +00:00
|
|
|
fintl.bindtextdomain(domain, localedir)
|
|
|
|
|
fintl.textdomain(domain)
|
2000-12-22 16:25:32 +00:00
|
|
|
languages = []
|
|
|
|
|
for envvar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
|
|
|
|
|
if os.environ.has_key(envvar):
|
|
|
|
|
languages = string.split(os.environ[envvar], ':')
|
|
|
|
|
break
|
|
|
|
|
if languages:
|
|
|
|
|
LANG=string.upper(languages[0])
|
|
|
|
|
|
2000-04-30 22:34:43 +00:00
|
|
|
except ImportError:
|
|
|
|
|
def gettext(msg):
|
|
|
|
|
return msg
|
2000-05-28 23:49:42 +00:00
|
|
|
# set _ as an alias for gettext
|
|
|
|
|
_ = gettext
|
|
|
|
|
|
2001-04-03 18:59:38 +00:00
|
|
|
#import timeoutsocket
|
|
|
|
|
#timeoutsocket.setDefaultSocketTimeout(20)
|
2001-03-10 10:14:31 +00:00
|
|
|
|
2000-05-16 15:31:19 +00:00
|
|
|
import Config,UrlData,sys,lc_cgi
|
2001-05-24 15:48:07 +00:00
|
|
|
from debuglevels import *
|
|
|
|
|
debug = Config.debug
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2001-05-24 15:48:07 +00:00
|
|
|
def checkUrls(config):
|
2000-04-10 16:58:05 +00:00
|
|
|
""" checkUrls gets a complete configuration object as parameter where all
|
|
|
|
|
runtime-dependent options are stored.
|
|
|
|
|
If you call checkUrls more than once, you can specify different
|
|
|
|
|
configurations.
|
|
|
|
|
|
|
|
|
|
In the config object there are functions to get a new URL (getUrl) and
|
|
|
|
|
to check it (checkUrl).
|
|
|
|
|
"""
|
2001-05-24 15:48:07 +00:00
|
|
|
debug(HURT_ME_PLENTY, "threads", config['threads'])
|
2000-02-26 10:24:46 +00:00
|
|
|
config.log_init()
|
|
|
|
|
try:
|
|
|
|
|
while not config.finished():
|
|
|
|
|
if config.hasMoreUrls():
|
|
|
|
|
config.checkUrl(config.getUrl())
|
2001-01-06 18:00:43 +00:00
|
|
|
config.log_endOfOutput()
|
2000-02-26 10:24:46 +00:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
config.finish()
|
|
|
|
|
config.log_endOfOutput()
|
2001-01-06 18:00:43 +00:00
|
|
|
sys.stderr.write("linkcheck: warning: keyboard interrupt\n")
|