mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-04 04:44:42 +00:00
new --status option
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1141 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
45620a8453
commit
a7607f3858
4 changed files with 27 additions and 1 deletions
|
|
@ -107,6 +107,7 @@ class Configuration (dict):
|
|||
self["wait"] = 0
|
||||
self['cookies'] = False
|
||||
self["strict"] = False
|
||||
self["status"] = False
|
||||
self["fileoutput"] = []
|
||||
# Logger configurations
|
||||
self["text"] = {
|
||||
|
|
@ -178,6 +179,10 @@ class Configuration (dict):
|
|||
def setThreads (self, num):
|
||||
debug(HURT_ME_PLENTY, "set threading with %d threads", num)
|
||||
self.threader.threads_max = num
|
||||
if num>0:
|
||||
sys.setcheckinterval(50)
|
||||
else:
|
||||
sys.setcheckinterval(100)
|
||||
|
||||
|
||||
def newLogger (self, logtype, dict={}):
|
||||
|
|
|
|||
|
|
@ -57,7 +57,10 @@ def checkUrls (config):
|
|||
to check it (checkUrl).
|
||||
"""
|
||||
config.log_init()
|
||||
from linkcheck.log import strduration
|
||||
try:
|
||||
start_time = time.time()
|
||||
status_time = start_time
|
||||
while not config.finished():
|
||||
if config.hasMoreUrls():
|
||||
config.checkUrl(config.getUrl())
|
||||
|
|
@ -65,9 +68,19 @@ def checkUrls (config):
|
|||
# active connections are downloading/parsing, so
|
||||
# wait a little
|
||||
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)
|
||||
status_time = curtime
|
||||
config.log_endOfOutput()
|
||||
except KeyboardInterrupt:
|
||||
config.finish()
|
||||
config.log_endOfOutput()
|
||||
warn(i18n._("keyboard interrupt; waiting for active connections to finish"))
|
||||
active = config.threader.active_threads()
|
||||
warn(i18n._("keyboard interrupt; waiting for %d active threads to finish") % active)
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ For single-letter option arguments the space is not a necessity. So
|
|||
Check only syntax of external links, do not try to connect to them.
|
||||
For local file urls, only local files are internal. For
|
||||
http and ftp urls, all urls at the same domain name are internal.
|
||||
--status
|
||||
Regularly print numbers of urls checked and still to check.
|
||||
-t num, --threads=num
|
||||
Generate no more than num threads. Default number of threads is 5.
|
||||
To disable threading specify a non-positive number.
|
||||
|
|
@ -243,6 +245,7 @@ try:
|
|||
"wischiwaschi",
|
||||
"robots-txt",
|
||||
"strict",
|
||||
"status",
|
||||
"threads=",
|
||||
"timeout=",
|
||||
"user=",
|
||||
|
|
@ -355,6 +358,9 @@ for opt,arg in options:
|
|||
elif opt=="-s" or opt=="--strict":
|
||||
config["strict"] = True
|
||||
|
||||
elif opt=="--status":
|
||||
config['status'] = True
|
||||
|
||||
elif opt=="-t" or opt=="--threads":
|
||||
try:
|
||||
config.setThreads(int(arg))
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
# turn on/off debug messages
|
||||
# use higher numbers for more debugging
|
||||
#debug=2
|
||||
# print status output
|
||||
#status=1
|
||||
# change the logging type
|
||||
#log=colored
|
||||
# turn on/off --verbose
|
||||
|
|
|
|||
Loading…
Reference in a new issue