Commit 1c68074b authored by Nicolas Delaby's avatar Nicolas Delaby Committed by Arnaud Fontaine

Various improvement to enhance portability:

  - Use parsable Configuration file respective ConfigParser module
  - Update documentation with sample of configuration file
  - Create entry_point for console named web_checker_utility


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils/erp5.utils.web_checker/@37449 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fe9b836f
Utility able to call wget and varnishlog to extract Headers and return all failures
according expected caching policy.
This utility is configurable through a dictionnary like
configuration = {'url': 'http://www.example.com',
'working_directory': '/home/me/tmp/crawled_content',
'varnishlog_binary_path': 'varnishlog',
'header_list': {'Last-Modified': True,
'Cache-Control': ('max-age=300', 'max-age=3600',),
'Vary' : ('Accept-Language, Cookie', 'Accept-Language,Cookie'),
'Expires': True,
},
'email_address': 'me@example.com',
'smtp_host': 'localhost',
'debug_level': 'debug',
}
This utility is configurable through a configuration file like:
url : website to check
working_directory : fetched data will be downloaded
varnishlog_binary_path : path to varnishlog
header_list : Key == Header id.
[web_checker]
url = http://www.example.com/
working_directory = /home/me/tmp/crawled_content
varnishlog_binary_path = varnishlog
email_address = me@example.com
smtp_host = localhost
debug_level = debug
[header_list]
Last-Modified = True
Cache-Control = max-age=300
max-age=3600
Vary = Accept-Language, Cookie, Accept-Encoding
Accept-Language, Cookie
Accept-Language,Cookie,Accept-Encoding
Accept-Language,Cookie
Expires = True
with
url : website to check
working_directory : fetched data will be downloaded
varnishlog_binary_path : path to varnishlog
header_list : Key == Header id.
value: if equals to True, it means that header needs to be present in RESPONSE
if it is a tuple, the Header value must sastify at least one of the proposed values
email_address : email address to send result
smtp_host : smtp host to use
debug_level : log level of this utility (debug =>very verbose,
email_address : email address to send result
smtp_host : smtp host to use
debug_level : log level of this utility (debug =>very verbose,
info=>normal,
warning=>nothing)
......
......@@ -379,3 +379,45 @@ class HTTPCacheCheckerTestSuite(object):
return 'Email sends to %s' % self.email_address
else:
return report_message
from optparse import OptionParser
import ConfigParser
def web_checker_utility():
usage = "usage: %prog config_path"
parser = OptionParser(usage=usage)
(options, args) = parser.parse_args()
if len(args) != 1 :
print parser.print_help()
parser.error('incorrect number of arguments')
config_path = args[0]
config = ConfigParser.RawConfigParser()
config.read(config_path)
working_directory = config.get('web_checker', 'working_directory')
url = config.get('web_checker', 'url')
varnishlog_binary_path = config.get('web_checker' , 'varnishlog_binary_path')
header_list = {}
for header, configuration in config.items('header_list'):
if configuration in ('True', 'true', 'yes'):
value = True
else:
value = configuration.splitlines()
header_list[header] = value
email_address = config.get('web_checker' , 'email_address')
smtp_host = config.get('web_checker' , 'smtp_host')
debug_level = config.get('web_checker' , 'debug_level')
instance = HTTPCacheCheckerTestSuite(url,
working_directory,
varnishlog_binary_path,
header_list,
email_address,
smtp_host,
debug_level)
print instance.start()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment