diff --git a/linkcheck/UrlData.py b/linkcheck/UrlData.py index ada0b9fe..c9714f02 100644 --- a/linkcheck/UrlData.py +++ b/linkcheck/UrlData.py @@ -18,11 +18,6 @@ import sys, re, urlparse, urllib2, time, traceback, socket, select, i18n from urllib import splituser, splitport, unquote -#try: -# from linkcheck import DNS -#except ImportError: -# print >>sys.stderr, "You have to install PyDNS from http://pydns.sf.net/" -# raise SystemExit from linkcheck import DNS, LinkCheckerError, getLinkPat DNS.DiscoverNameServers() @@ -379,7 +374,8 @@ class UrlData (object): # check recursion debug(BRING_IT_ON, "checking recursion") if self.allowsRecursion(): - try: self.parseUrl() + try: + self.parseUrl() except tuple(ExcList): value, tb = sys.exc_info()[1:] debug(HURT_ME_PLENTY, "exception", traceback.format_tb(tb)) diff --git a/linkcheck/__init__.py b/linkcheck/__init__.py index b2a72319..d723932b 100644 --- a/linkcheck/__init__.py +++ b/linkcheck/__init__.py @@ -45,6 +45,7 @@ extensions = { import UrlData from debug import * +from linkcheck.log import strduration # main check function def checkUrls (config): @@ -57,7 +58,6 @@ def checkUrls (config): to check it (checkUrl). """ config.log_init() - from linkcheck.log import strduration try: start_time = time.time() status_time = start_time @@ -70,12 +70,8 @@ def checkUrls (config): time.sleep(0.1) if config['status']: curtime = time.time() - tocheck = config.urls.qsize() - active = config.threader.active_threads() - links = config['linknumber'] - duration = strduration(curtime - start_time) if (curtime - status_time) > 5: - print >>sys.stderr, i18n._("%5d urls queued, %4d links checked, %2d active threads, runtime %s")%(tocheck, links, active, duration) + printStatus(config, curtime, start_time) status_time = curtime config.log_endOfOutput() except KeyboardInterrupt: @@ -84,3 +80,12 @@ def checkUrls (config): active = config.threader.active_threads() warn(i18n._("keyboard interrupt; waiting for %d active threads to finish") % active) raise + + +def printStatus (config, curtime, start_time): + tocheck = config.urls.qsize() + links = config['linknumber'] + active = config.threader.active_threads() + duration = strduration(curtime - start_time) + print >>sys.stderr, i18n._("%5d urls queued, %4d links checked, %2d active threads, runtime %s")%\ + (tocheck, links, active, duration)