[Erp5-report] r33962 rafael - in /erp5/trunk/utils/erp5.recipe.mysqlserver: ./ src/erp5/rec...

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Mar 22 18:35:13 CET 2010


Author: rafael
Date: Mon Mar 22 18:35:12 2010
New Revision: 33962

URL: http://svn.erp5.org?rev=33962&view=rev
Log:
Use zc.buildout.easy_install.scripts to generate scripts to run and manage the Mysql server instance.


Added:
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/ctl.py
Modified:
    erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt
    erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py

Modified: erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt?rev=33962&r1=33961&r2=33962&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt [utf8] Mon Mar 22 18:35:12 2010
@@ -1,5 +1,12 @@
 Changelog
 =========
+
+1.0.1 (2010-03-22)
+------------------
+
+- Use zc.buildout.easy_install.scripts to generate scripts to run the 
+  Mysql server instance.
+  [Rafael Monnerat]
 
 1.0 (2010-03-19)
 ----------------

Modified: erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py?rev=33962&r1=33961&r2=33962&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py [utf8] Mon Mar 22 18:35:12 2010
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 
 name = "erp5.recipe.mysqlserver"
-version = '1.0'
+version = '1.0.1'
 
 def read(name):
     return open(name).read()

Modified: erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py?rev=33962&r1=33961&r2=33962&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py [utf8] Mon Mar 22 18:35:12 2010
@@ -17,11 +17,15 @@
 import logging
 from time import sleep
 import subprocess
+import zc.buildout
+import zc.buildout.easy_install
+import zc.recipe.egg
 
 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(
@@ -42,37 +46,22 @@
     stdout, stderr = process.communicate()
     return stdout, stderr
 
-  def _writeFile(self, path, content, force=1):
-    """ Create one file with a certain content
-    """
-    if not os.path.exists(path) or force:
-      f = open(path, 'w')
-      f.write('%s' % content)
-      f.close()
-    else:
-      # XXX raise "What?"
-      print "*"*99
-      pass
-      
-  def _createExecutable(self, command):
-    """
-      Create commands to manage mysql like:
-        mysql , mysqldump
+  def install_script(self, script_name):
+    """ Create default scripts
     """
     options = self.options
     mysql_software_bin = options.get("mysql_software_bin")
     mysql_cnf_file = options.get("mysql_cnf_file")
-    mysql_bin_folder = options.get("mysql_bin_folder")
-
-    # Write mysql command
-    mysql_content = MYSQL_COMMAND_TEMPLATE % \
-                            (dict(mysql_software_bin=mysql_software_bin,
-                                  command=command,
-                                  mysql_cnf_file=mysql_cnf_file))
-
-    command_path = "%s/%s" % (mysql_bin_folder, command)
-    self._writeFile(command_path, mysql_content)
-    os.chmod(command_path, 0755)
+    requirements, ws = self.egg.working_set(['erp5.recipe.mysqlserver'])
+    
+    scripts = zc.buildout.easy_install.scripts(
+        [(script_name,'erp5.recipe.mysqlserver.ctl', 'main')], 
+        ws, options['executable'], options.get("mysql_bin_folder"),
+        arguments = ("\n        ['%s/%s' ,"
+                     "\n        '--defaults-file=%s'] "
+                     "\n        + sys.argv[1:]" % (mysql_software_bin, 
+                                                   script_name, 
+                                                   mysql_cnf_file)))
 
   def install(self):
     options = self.options
@@ -90,10 +79,10 @@
 
       self._popen(command)
 
-    self._createExecutable("mysql")
-    self._createExecutable("mysqld_safe")
-    self._createExecutable("mysqladmin")
-    self._createExecutable("mysqldump")
+    self.install_script('mysql')
+    self.install_script("mysqld_safe")
+    self.install_script("mysqladmin")
+    self.install_script("mysqldump")
 
     if options.get("mysql_auto_start").lower() == "true":
       mysql_bin_folder = options.get("mysql_bin_folder")
@@ -101,12 +90,7 @@
       subprocess.call(command, shell=True)
       sleep(20)
 
-
     return location
 
   update = install
 
-
-MYSQL_COMMAND_TEMPLATE = """#!/bin/sh
-%(mysql_software_bin)s/%(command)s --defaults-file=%(mysql_cnf_file)s $@
-"""

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/ctl.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/ctl.py?rev=33962&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/ctl.py (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/ctl.py [utf8] Mon Mar 22 18:35:12 2010
@@ -1,0 +1,32 @@
+# -*- 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.
+#
+##############################################################################
+
+#
+# Draft script to wrapper mysql programs calls.
+# This script can be improved to provide more features
+# in future.
+#
+
+import subprocess
+
+def main(argv_list):
+  """ Simply merge arguments and run it.
+  """
+  command = ' '.join(argv_list)
+  subprocess.call(command, shell=True)
+  
+if __name__ == "__main__":
+  import sys
+  main(sys.argv[1:])




More information about the Erp5-report mailing list