Allow maximum check time specification.

This commit is contained in:
Bastian Kleineidam 2012-09-03 20:17:49 +02:00
parent 8ddd568a4c
commit 6730fb51ee
7 changed files with 25 additions and 8 deletions

View file

@ -174,7 +174,9 @@
# that are already expired.
# The default number of days is 14.
#sslcertwarndays=14
# Stop checking new URLs after the given number of seconds. Same as if the
# user hits Ctrl-C after X seconds.
#maxrunseconds=600
##################### filtering options ##########################
[filtering]

View file

@ -1,5 +1,8 @@
8.1 "" (release xx.xx.2012)
Features:
- checking: Allow specification of maximum checking time or maximum
number of checked URLs.
8.0 "Luminaris" (released 2.9.2012)

View file

@ -1,3 +0,0 @@
Features:
- checking: Allow specification of maximum checking time or maximum
number of checked URLs.

View file

@ -222,6 +222,7 @@ class Configuration (dict):
self["debugmemory"] = False
self["localwebroot"] = None
self["warnsslcertdaysvalid"] = 14
self["maxrunseconds"] = None
from ..logger import Loggers
self.loggers = dict(**Loggers)

View file

@ -153,6 +153,7 @@ class LCConfigParser (ConfigParser.RawConfigParser, object):
self.read_string_option(section, "cookiefile")
self.read_string_option(section, "localwebroot")
self.read_int_option(section, "warnsslcertdaysvalid")
self.read_int_option(section, "maxrunseconds")
def read_authentication_config (self):
"""Read configuration options in section "authentication"."""

View file

@ -47,7 +47,8 @@ class Aggregate (object):
"""Spawn threads for URL checking and status printing."""
if self.config["status"]:
t = status.Status(self.urlqueue, self.config.status_logger,
self.config["status_wait_seconds"])
self.config["status_wait_seconds"],
self.config["maxrunseconds"])
t.start()
self.threads.append(t)
t = cleanup.Cleanup(self.connections)

View file

@ -1,5 +1,5 @@
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2006-2011 Bastian Kleineidam
# Copyright (C) 2006-2012 Bastian Kleineidam
#
# 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
@ -22,11 +22,21 @@ from . import task
class Status (task.LoggedCheckedTask):
"""Status thread."""
def __init__ (self, urlqueue, logger, wait_seconds):
"""Store urlqueue object."""
def __init__ (self, urlqueue, logger, wait_seconds, max_duration):
"""Initialize the status logger task.
@param urlqueue: the URL queue
@ptype urlqueue: Urlqueue
@param logger: the logger object to inform about status
@ptype logger: console.StatusLogger
@param wait_seconds: interval in seconds to report status
@ptype wait_seconds: int
@param max_duration: abort checking after given number of seconds
@ptype max_duration: int or None
"""
super(Status, self).__init__(logger)
self.urlqueue = urlqueue
self.wait_seconds = wait_seconds
self.max_duration = max_duration
def run_checked (self):
"""Print periodic status messages."""
@ -38,5 +48,7 @@ class Status (task.LoggedCheckedTask):
def log_status (self):
"""Log a status message."""
duration = time.time() - self.start_time
if self.max_duration is not None and duration > self.max_duration:
raise KeyboardInterrupt()
checked, in_progress, queue = self.urlqueue.status()
self.logger.log_status(checked, in_progress, queue, duration)