[Erp5-report] r37449 nicolas - in /erp5/trunk/utils/erp5.utils.web_checker: ./ src/erp5/uti...
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Aug 3 17:08:48 CEST 2010
Author: nicolas
Date: Tue Aug 3 17:08:44 2010
New Revision: 37449
URL: http://svn.erp5.org?rev=37449&view=rev
Log:
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
Modified:
erp5/trunk/utils/erp5.utils.web_checker/README.txt
erp5/trunk/utils/erp5.utils.web_checker/setup.py
erp5/trunk/utils/erp5.utils.web_checker/src/erp5/utils/web_checker/__init__.py
Modified: erp5/trunk/utils/erp5.utils.web_checker/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.utils.web_checker/README.txt?rev=37449&r1=37448&r2=37449&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.utils.web_checker/README.txt [utf8] (original)
+++ erp5/trunk/utils/erp5.utils.web_checker/README.txt [utf8] Tue Aug 3 17:08:44 2010
@@ -1,31 +1,39 @@
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 at example.com',
- 'smtp_host': 'localhost',
- 'debug_level': 'debug',
- }
-
-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,
- info=>normal,
- warning=>nothing)
+This utility is configurable through a configuration file like:
+
+[web_checker]
+url = http://www.example.com/
+working_directory = /home/me/tmp/crawled_content
+varnishlog_binary_path = varnishlog
+email_address = me at 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,
+ info=>normal,
+ warning=>nothing)
This utility requires wget => 1.12
And a callable varnishlog.
Modified: erp5/trunk/utils/erp5.utils.web_checker/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.utils.web_checker/setup.py?rev=37449&r1=37448&r2=37449&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.utils.web_checker/setup.py [utf8] (original)
+++ erp5/trunk/utils/erp5.utils.web_checker/setup.py [utf8] Tue Aug 3 17:08:44 2010
@@ -31,7 +31,11 @@ setup(name=name,
author='Nicolas Delaby',
author_email='nicolas at nexedi.com',
url='http://www.erp5.org/',
- package_dir = {'':'src'},
- packages = find_packages('src'),
+ package_dir={'':'src'},
+ packages=find_packages('src'),
+ namespace_packages=['erp5', 'erp5.utils'],
include_package_data=True,
- )
+ entry_points = {
+ 'console_scripts' : ['web_checker_utility = erp5.utils.web_checker:web_checker_utility',]
+ }
+ )
Modified: erp5/trunk/utils/erp5.utils.web_checker/src/erp5/utils/web_checker/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.utils.web_checker/src/erp5/utils/web_checker/__init__.py?rev=37449&r1=37448&r2=37449&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.utils.web_checker/src/erp5/utils/web_checker/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.utils.web_checker/src/erp5/utils/web_checker/__init__.py [utf8] Tue Aug 3 17:08:44 2010
@@ -378,4 +378,46 @@ class HTTPCacheCheckerTestSuite(object):
server.quit()
return 'Email sends to %s' % self.email_address
else:
- return report_message
\ No newline at end of file
+ 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()
+
+
More information about the Erp5-report
mailing list