[Erp5-report] r36342 cedric.dsm - in /erp5/trunk/utils/erp5.recipe.memcachedserver: ./ src/...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Jun 15 11:05:56 CEST 2010


Author: cedric.dsm
Date: Tue Jun 15 11:05:43 2010
New Revision: 36342

URL: http://svn.erp5.org?rev=36342&view=rev
Log:
erp5.recipe.memcachedserver v0.0.2 : 
- Parsing correctly the "run_as_daemon" string to boolean, 
- Using generic "instancehome" name for the memcached home directory

Modified:
    erp5/trunk/utils/erp5.recipe.memcachedserver/CHANGES.txt
    erp5/trunk/utils/erp5.recipe.memcachedserver/setup.py
    erp5/trunk/utils/erp5.recipe.memcachedserver/src/erp5/recipe/memcachedserver/__init__.py

Modified: erp5/trunk/utils/erp5.recipe.memcachedserver/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.memcachedserver/CHANGES.txt?rev=36342&r1=36341&r2=36342&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.memcachedserver/CHANGES.txt [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.memcachedserver/CHANGES.txt [utf8] Tue Jun 15 11:05:43 2010
@@ -1,9 +1,17 @@
 Changelog
 =========
 
+0.0.2 (2010-06-15)
+----------------
+
+- Now creates a "memcached" directory in var to store the pidfile.
+- Fixes a bug in which memcached run as daemon even if the contrary is specified
+in the recipe.
+  [Cedric de Saint Martin]
+
+
 0.0.1 (2010-06-11)
 ----------------
 
 - Initial version
   [Cedric de Saint Martin]
-

Modified: erp5/trunk/utils/erp5.recipe.memcachedserver/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.memcachedserver/setup.py?rev=36342&r1=36341&r2=36342&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.memcachedserver/setup.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.memcachedserver/setup.py [utf8] Tue Jun 15 11:05:43 2010
@@ -2,7 +2,7 @@ from setuptools import setup, find_packa
 import os
 
 name = "erp5.recipe.memcachedserver"
-version = '0.0.1'
+version = '0.0.2'
 
 def read(*rnames):
   return open(os.path.join(os.path.dirname(__file__), *rnames)).read()

Modified: erp5/trunk/utils/erp5.recipe.memcachedserver/src/erp5/recipe/memcachedserver/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.memcachedserver/src/erp5/recipe/memcachedserver/__init__.py?rev=36342&r1=36341&r2=36342&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.memcachedserver/src/erp5/recipe/memcachedserver/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.memcachedserver/src/erp5/recipe/memcachedserver/__init__.py [utf8] Tue Jun 15 11:05:43 2010
@@ -31,13 +31,34 @@ class Recipe(object):
     self.logger=logging.getLogger(self.name)
 
 
+  def parseBoolean(self, b):
+    # Handle case where b is already a Boolean type.
+    if b == False or b == True:
+      return b
+    b = b.strip()
+    if len(b) < 1:
+      raise ValueError('Cannot parse empty string into boolean.')
+    b = b[0].lower()
+    if b == 't' or b == '1' or b == 'y':
+      return True
+    return False
+
+  def createDirIfNeeded(self, path):
+    # Checks directory existence. If not, creates it
+    if not os.path.isdir(path):
+      self.logger.info("Creating %s directory..." % path)
+      os.makedirs(path)
+
   def install_script(self, script_name):
     """ Create default scripts
     """
     self.logger.info('Installing memcached wrapper script...')
     options = self.options
     memcached_software_bin = options.get("memcached_software_bin")
+    memcached_bin_folder = options.get("memcached_bin_folder")
     memcached_conf_file = options.get("memcached_conf_file")
+
+    self.createDirIfNeeded(memcached_bin_folder)
     # Warning : if python2.4 is not installed with buildout you will get a
     # "ValueError: too many values to unpack" error.
     # To avoid this, make sure python2.4 is installed by buildout
@@ -46,7 +67,7 @@ class Recipe(object):
     requirements, ws = self.egg.working_set(['erp5.recipe.memcachedserver'])
     zc.buildout.easy_install.scripts(
       [(script_name,'erp5.recipe.memcachedserver.ctl', 'main')],
-      ws, options['executable'], options.get("memcached_bin_folder"),
+      ws, options['executable'], memcached_bin_folder,
       arguments = ("\n        '%s/%s' ,"
                    "\n        '%s' " % (memcached_software_bin,
                                          script_name,
@@ -66,11 +87,8 @@ class Recipe(object):
     factor = self.options.get('memcached_factor')
     key_size = self.options.get('memcached_key_size')
     threads = self.options.get('memcached_threads')
-  
-    # Checks configuration directory existence. If not, creates it
-    confpath = os.path.dirname(config_file_location)
-    if not os.path.isdir(confpath):
-      os.makedirs(confpath)
+
+    self.createDirIfNeeded(os.path.dirname(config_file_location))
     
     # Creates config file
     self.logger.info('Creating memcached config file...')
@@ -89,8 +107,8 @@ class Recipe(object):
         simultaneous_connections)
     if user: 
       config.set('memcached', 'user', user)
-    if "true" in run_as_daemon:
-      config.set('memcached', 'run_as_daemon', run_as_daemon)
+    if self.parseBoolean(run_as_daemon):
+      config.set('memcached', 'run_as_daemon', 'true')
     if pid_file: 
       config.set('memcached', 'pid_file', pid_file)
     if factor: 
@@ -111,10 +129,8 @@ class Recipe(object):
 
 
   def install(self):
-    home = self.options.get('memcached_home')
-    # Checks memcached home directory existence. If not, creates it
-    if not os.path.isdir(home):
-      os.makedirs(home)
+    home = self.options.get('instancehome')
+    self.createDirIfNeeded(home)
     
     self.build_configuration_file()
     self.install_script('memcached')




More information about the Erp5-report mailing list