[Erp5-report] r39316 nicolas - in /erp5/trunk/utils/erp5.recipe.web_checker: ./ src/ src/er...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Oct 19 09:29:20 CEST 2010


Author: nicolas
Date: Tue Oct 19 09:29:19 2010
New Revision: 39316

URL: http://svn.erp5.org?rev=39316&view=rev
Log:
Initial release of erp5.recipe.web_checker. The recipe to instanciate
web_checker utility.

Added:
    erp5/trunk/utils/erp5.recipe.web_checker/
    erp5/trunk/utils/erp5.recipe.web_checker/CHANGES.txt
    erp5/trunk/utils/erp5.recipe.web_checker/README.txt
    erp5/trunk/utils/erp5.recipe.web_checker/setup.py
    erp5/trunk/utils/erp5.recipe.web_checker/src/
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/__init__.py
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/__init__.py
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/__init__.py
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/ctl.py
    erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/web_checker_configuration.cnf.in

Added: erp5/trunk/utils/erp5.recipe.web_checker/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/CHANGES.txt?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/CHANGES.txt (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/CHANGES.txt [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,10 @@
+Changelog
+=========
+
+0.0.2 (unreleased)
+------------------
+
+0.0.1 (2010-10-19)
+------------------
+- initial implementation
+  [Nicolas Delaby]
\ No newline at end of file

Added: erp5/trunk/utils/erp5.recipe.web_checker/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/README.txt?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/README.txt (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/README.txt [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,52 @@
+Introduction
+============
+
+This recipe create and configure an instance of web_checker utility.
+(erp5.utils.web_checker)
+
+Example
+=======
+
+You can use it with a part like this::
+
+  [web-checker-instance]
+  recipe = erp5.recipe.web_checker
+  web_checker_software_home = /path_to_web_checker_software
+  url = http://www.example.com/
+  email_address = me at erp5.com
+
+
+Options
+=======
+
+wget_binary_path
+  path of executable wget
+
+varnishlog_binary_path
+  path to executable varnishlog
+
+working_directory
+  Where wget will download web_sites.
+
+smtp_host
+  hostname of smtp server
+
+debug_level
+  verbosity of logging
+
+file_log_path
+  path of logging file
+
+header_list
+  Dictionary with key as HTTP Header to check and values, are expected values.
+
+  {"Last-Modified": true,
+   "Cache-Control": ["max-age=300", "max-age=3600"],
+   "Vary": ["Accept-Language, Cookie, Accept-Encoding", "Accept-Language,Cookie"],
+   "Expires": true}
+
+erp5_extension_list
+  List of files prohibited links, as filename or folder name.
+
+  {"prohibited_file_name_list": ["WebSection_viewAsWeb", "Base_viewHistory", "list"],
+   "prohibited_folder_name_list": ["web_page_module", "document_module"]}

Added: erp5/trunk/utils/erp5.recipe.web_checker/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/setup.py?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/setup.py (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/setup.py [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+from setuptools import setup, find_packages
+
+name = "erp5.recipe.web_checker"
+version = '0.0.1'
+
+def read(name):
+    return open(name).read()
+
+long_description=( read('README.txt')
+                   + '\n' +
+                   read('CHANGES.txt')
+                 )
+
+setup(
+    name = name,
+    version = version,
+    author = "Nicolas Delaby",
+    author_email = "nicolas at nexedi.com",
+    description = "ZC Buildout recipe for create a web_checker instance",
+    long_description=long_description,
+    license = "ZPL 2.1",
+    keywords = "web checker buildout",
+    classifiers=[
+        "License :: OSI Approved :: Zope Public License",
+        "Framework :: Buildout",
+        ],
+    packages = find_packages('src'),
+    package_dir = {'': 'src'},
+    include_package_data = True,
+    install_requires = [
+      'setuptools',
+      'zc.recipe.egg',
+      'simplejson',
+      ],
+    namespace_packages = ['erp5', 'erp5.recipe'],
+    entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
+    tests_require = [
+      'zope.testing',
+      ],
+    #test_suite = 'erp5.recipe.web_checker.tests',
+    )

Added: erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/__init__.py?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/__init__.py [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+  __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+  from pkgutil import extend_path
+  __path__ = extend_path(__path__, __name__) 

Added: erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/__init__.py?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/__init__.py [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+  __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+  from pkgutil import extend_path
+  __path__ = extend_path(__path__, __name__) 

Added: erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/__init__.py?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/__init__.py [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,115 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+from string import Template
+import logging
+import zc.buildout
+import zc.buildout.easy_install
+import zc.recipe.egg
+import pkg_resources
+import simplejson as json
+
+
+class Recipe(object):
+  def __init__(self, buildout, name, options):
+    self.buildout, self.options, self.name = buildout, options, name
+    self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options)
+    self.logger=logging.getLogger(self.name)
+
+    options['location'] = os.path.join(
+        buildout['buildout']['parts-directory'],
+        self.name)
+
+    options.setdefault('varnishlog_binary_path', 'varnishlog')
+    options.setdefault('wget_binary_path', 'wget')
+    options.setdefault('smtp_host', 'localhost')
+    options.setdefault('debug_level', 'info')
+    options.setdefault('working_directory', 'working_directory')
+    options.setdefault('header_list', '')
+    options.setdefault('erp5_extension_list', '')
+    options.setdefault('file_log_path', options['location'] + os.path.sep\
+                                        + name + '.log')
+
+  def install_script(self):
+    """ Create default script
+    """
+    options = self.options
+    requirements, ws = self.egg.working_set(['erp5.recipe.web_checker'])
+    web_checker_binary = os.path.sep.join(
+                                         (options['web_checker_software_home'],
+                                          'bin', 'web_checker_utility'))
+    configuration_file_path = options['configuration_file_path']
+    scripts = zc.buildout.easy_install.scripts(
+        [('web_checker_utility_instance_bin',
+          'erp5.recipe.web_checker.ctl',
+          'main')],
+        ws, options['executable'], options['bin-directory'],
+        arguments = ('[%r, %r] + sys.argv[1:]' % (web_checker_binary,
+                                                  configuration_file_path,)))
+
+  def build_configuration_file(self):
+    options = self.options
+    template_input_data = pkg_resources.resource_stream(__name__,
+          'web_checker_configuration.cnf.in').read()
+    processed_template = Template(template_input_data).\
+                                                     substitute(options.copy())
+    def makeConfigurationString(section, data):
+      """
+      """
+      indent = ' ' * 2
+      separator = '\n%s' % indent
+      string_to_append = '\n\n[%s]' % (section,)
+      header_dict = json.loads(data)
+      for key, value in header_dict.iteritems():
+        string_to_append += '\n%s = ' % (key,)
+        if isinstance(value, list):
+          string_to_append += separator
+          string_to_append += separator.join(value)
+        else:
+          string_to_append += str(value)
+      return string_to_append
+
+    if options['header_list']:
+      processed_template += makeConfigurationString('header_list',
+                                                    options['header_list'])
+    if options['erp5_extension_list']:
+      processed_template += makeConfigurationString('erp5_extension_list',
+                                                options['erp5_extension_list'])
+    processed_template += '\n'
+    file(options['configuration_file_path'], 'w').write(processed_template)
+
+  def install(self):
+    options = self.options
+    configuration_file_path = os.path.sep.join((options['location'],
+                                                self.name + '.conf',))
+    options['configuration_file_path'] = configuration_file_path
+
+    working_directory = options['working_directory']
+    working_directory = os.path.sep.join((options['location'],
+                                          working_directory))
+    options['working_directory'] = working_directory
+    if not os.path.exists(options['location']):
+      os.mkdir(options['location'])
+    working_directory = self.options['working_directory']
+    if not os.path.exists(working_directory):
+      os.mkdir(working_directory)
+
+    self.build_configuration_file()
+    self.install_script()
+
+    return [options['location']]
+
+  update = install

Added: erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/ctl.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/ctl.py?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/ctl.py (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/ctl.py [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+from os import execl
+import sys
+
+def main(args):
+  sys.stdout.flush()
+  execl(args[0], args[0], *args[1:])
+
+if __name__ == "__main__":
+  main(*sys.argv[1:])

Added: erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/web_checker_configuration.cnf.in
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/web_checker_configuration.cnf.in?rev=39316&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/web_checker_configuration.cnf.in (added)
+++ erp5/trunk/utils/erp5.recipe.web_checker/src/erp5/recipe/web_checker/web_checker_configuration.cnf.in [utf8] Tue Oct 19 09:29:19 2010
@@ -0,0 +1,9 @@
+[web_checker]
+url = ${url}
+working_directory = ${working_directory}
+varnishlog_binary_path = ${varnishlog_binary_path}
+wget_binary_path = ${wget_binary_path}
+email_address = ${email_address}
+smtp_host = ${smtp_host}
+debug_level = ${debug_level}
+file_log_path = ${file_log_path}
\ No newline at end of file




More information about the Erp5-report mailing list