zc buildout recipe执行命令行
iw.recipe.cmd的Python项目详细描述
警告:此包已弃用。您应该使用collective.recipe.cmd
内容
- 代码库:https://ingeniweb.svn.sourceforge.net/svnroot/ingeniweb/iw.recipe.cmd/trunk
- 对support@ingeniweb.com 的问题和评论
- 在http://trac.ingeniweb.com/ 报告错误
Change history
trunk (2008-04-22)
- xxx [Ingeniweb]
0.3 (2008-04-22)
- apply last version of the recipe template [gawel]
0.2 (2008-04-22)
- run commands in one process [gawel]
- win32 tests compat [gawel]
Detailed Documentation
Supported options
配方支持以下选项:
安装时
true if the commands must run on install
更新时
true if the commands must run on update
指挥管理系统
a set of command lines
外壳
a valid interpreter (POSIX only)
Example usage
我们需要一个配置文件:
>>> cfg = """ ... [buildout] ... parts = cmds ... ... [cmds] ... recipe = iw.recipe.cmd ... on_install=true ... cmds= %s ... """ >>> test_file = join(sample_buildout, 'test.txt') >>> cmds = 'echo "bouh" > %s' % test_file >>> write(sample_buildout, 'buildout.cfg', cfg % cmds)
好的,现在我们可以触摸文件进行测试:
>>> print system(buildout) Installing cmds. >>> 'test.txt' in os.listdir(sample_buildout) True
并将其删除:
>>> test_file = join(sample_buildout, 'test.txt') >>> if sys.platform == 'win32': ... cmds = 'del %s' % test_file ... else: ... cmds = 'rm -f %s' % test_file >>> write(sample_buildout, 'buildout.cfg', cfg % cmds) >>> print system(buildout) Uninstalling cmds. Installing cmds. >>> 'test.txt' in os.listdir(sample_buildout) False
我们可以运行多个命令:
>>> if sys.platform == 'win32': ... cmds = ''' ... echo "bouh" > %s ... del %s ... ''' % (test_file, test_file) ... else: ... cmds = ''' ... echo "bouh" > %s ... rm -f %s ... ''' % (test_file, test_file) >>> test_file = join(sample_buildout, 'test.txt') >>> if sys.platform == 'win32': ... cmds = 'del %s' % test_file ... else: ... cmds = 'rm -f %s' % test_file >>> write(sample_buildout, 'buildout.cfg', cfg % cmds) >>> print system(buildout) Updating cmds. >>> 'test.txt' in os.listdir(sample_buildout) False
我们还可以运行一些python代码:
>>> cfg = """ ... [buildout] ... parts = py py2 ... ... [py] ... recipe = iw.recipe.cmd:py ... on_install=true ... cmds= ... >>> sample_buildout = buildout.get('directory', '.') ... >>> print sorted(os.listdir(sample_buildout)) ... >>> os.remove(os.path.join(sample_buildout, ".installed.cfg")) ... >>> print sorted(os.listdir(sample_buildout)) ... [py2] ... recipe = iw.recipe.cmd:py ... on_install=true ... cmds= ... >>> def myfunc(value): ... ... return value and True or False ... >>> v = 20 ... >>> print myfunc(v) ... """ >>> write(sample_buildout, 'buildout.cfg', cfg)
好的,现在我们运行它:
>>> print system(buildout) Uninstalling cmds. Installing py. ['.installed.cfg', 'bin', 'buildout.cfg', 'develop-eggs', 'eggs', 'parts'] ['bin', 'buildout.cfg', 'develop-eggs', 'eggs', 'parts'] Installing py2. True
Contributors
盖尔帕斯格里莫德