[Checkins] SVN: zc.recipe.deployment/trunk/ Added recipe for
generating crontab files in /etc/cron.d.
Jim Fulton
jim at zope.com
Fri Mar 23 12:20:22 EDT 2007
Log message for revision 73486:
Added recipe for generating crontab files in /etc/cron.d.
Changed:
U zc.recipe.deployment/trunk/README.txt
U zc.recipe.deployment/trunk/setup.py
U zc.recipe.deployment/trunk/src/zc/recipe/deployment/README.txt
U zc.recipe.deployment/trunk/src/zc/recipe/deployment/__init__.py
-=-
Modified: zc.recipe.deployment/trunk/README.txt
===================================================================
--- zc.recipe.deployment/trunk/README.txt 2007-03-23 14:55:18 UTC (rev 73485)
+++ zc.recipe.deployment/trunk/README.txt 2007-03-23 16:20:21 UTC (rev 73486)
@@ -44,6 +44,14 @@
Changes
*******
+0.5 (Mar 23, 2007)
+==================
+
+Features Added
+--------------
+
+Added recipe for generating crontab files in /etc/cron.d.
+
0.4 (Mar 22, 2007)
==================
Modified: zc.recipe.deployment/trunk/setup.py
===================================================================
--- zc.recipe.deployment/trunk/setup.py 2007-03-23 14:55:18 UTC (rev 73485)
+++ zc.recipe.deployment/trunk/setup.py 2007-03-23 16:20:21 UTC (rev 73486)
@@ -8,6 +8,7 @@
default = %(name)s:Install
deployment = %(name)s:Install
configuration = %(name)s:Configuration
+crontab = %(name)s:Crontab
[zc.buildout.uninstall]
default = %(name)s:uninstall
@@ -19,7 +20,7 @@
setup(
name = name,
- version = '0.4',
+ version = '0.5',
author = 'Jim Fulton',
author_email = 'jim at zope.com',
description = 'ZC Buildout recipe for Unix deployments',
Modified: zc.recipe.deployment/trunk/src/zc/recipe/deployment/README.txt
===================================================================
--- zc.recipe.deployment/trunk/src/zc/recipe/deployment/README.txt 2007-03-23 14:55:18 UTC (rev 73485)
+++ zc.recipe.deployment/trunk/src/zc/recipe/deployment/README.txt 2007-03-23 16:20:21 UTC (rev 73486)
@@ -1,4 +1,4 @@
-Using the deplyment recipe is pretty simple. Simply specify a
+Using the deployment recipe is pretty simple. Simply specify a
deployment name, specified via the part name, and a deployment user.
Let's add a deployment to a sample buildout:
@@ -146,8 +146,8 @@
===================
Normally, configuration files are created by specialized recipes.
-Sometimes, it's useful to specifu configuration files in a buildout
-cnfiguration file. The zc.recipe.deployment:configuration recipe can be
+Sometimes, it's useful to specify configuration files in a buildout
+configuration file. The zc.recipe.deployment:configuration recipe can be
used to do that.
Let's add a configuration file to our buildout:
@@ -221,7 +221,7 @@
yyy
zzz
-We can read data from a fiile rather than specifying in the
+We can read data from a file rather than specifying in the
configuration:
>>> write('x.in', '1\n2\n3\n')
@@ -261,13 +261,49 @@
location = /etc/foo/x.cfg
...
+Cron support
+============
+The crontab recipe provides support for creating crontab files. It
+uses a times option to specify times to run the command and a command
+option containing the command.
+
+ >>> write('buildout.cfg',
+ ... '''
+ ... [buildout]
+ ... parts = foo cron
+ ...
+ ... [foo]
+ ... recipe = zc.recipe.deployment
+ ... user = jim
+ ...
+ ... [cron]
+ ... recipe = zc.recipe.deployment:crontab
+ ... times = 30 23 * * *
+ ... command = echo hello world!
+ ... deployment = foo
+ ... ''')
+
+ >>> print system(join('bin', 'buildout')),
+ buildout: Uninstalling x.cfg
+ buildout: Updating foo
+ buildout: Installing cron
+
+This example creates /etc/cron.d/foo-cron
+
+ >>> open('/etc/cron.d/foo-cron').read()
+ '30 23 * * *\tjim\techo hello world!\n'
+
.. cleanup
>>> print system(join('bin', 'buildout')+' buildout:parts='),
- buildout: Uninstalling x.cfg
+ buildout: Uninstalling cron
buildout: Uninstalling foo
buildout: Running uninstall recipe
zc.recipe.deployment: Removing '/etc/foo'
zc.recipe.deployment: Removing '/var/log/foo'.
zc.recipe.deployment: Removing '/var/run/foo'.
+
+ >>> os.path.exists('/etc/cron.d/foo-cron')
+ False
+
Modified: zc.recipe.deployment/trunk/src/zc/recipe/deployment/__init__.py
===================================================================
--- zc.recipe.deployment/trunk/src/zc/recipe/deployment/__init__.py 2007-03-23 14:55:18 UTC (rev 73485)
+++ zc.recipe.deployment/trunk/src/zc/recipe/deployment/__init__.py 2007-03-23 16:20:21 UTC (rev 73486)
@@ -120,3 +120,23 @@
return options['location']
update = install
+
+class Crontab:
+
+ def __init__(self, buildout, name, options):
+ self.name, self.options = name, options
+
+ deployment = options['deployment']
+ options['location'] = os.path.join(
+ buildout[deployment]['crontab-directory'],
+ deployment + '-' + name)
+ options['entry'] = '%s\t%s\t%s\n' % (
+ options['times'], buildout[deployment]['user'], options['command'])
+
+ def install(self):
+ options = self.options
+ open(options['location'], 'w').write(options['entry'])
+ return options['location']
+
+ update = install
+
More information about the Checkins
mailing list