collective.recipe.cmd
Introduction
collective.recipe.cmd is a Buildout recipe to execute commands in the console user interface.
Usage
Supported options
The recipe supports the following options:
- on_install
true if the commands must run on install
- on_update
true if the commands must run on update
- cmds
a set of command lines
- uninstall_cmds
a set of command lines executed in the buildout uninstall phase
- shell
a valid interpreter (POSIX only)
Example usage
We need a config file:
>>> cfg = """ ... [buildout] ... parts = cmds ... ... [cmds] ... recipe = collective.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)
Ok, so now we can touch a file for testing:
>>> print(system(buildout)) Installing cmds... >>> 'test.txt' in os.listdir(sample_buildout) True
And remove it:
>>> 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. Running uninstall recipe. Installing cmds... >>> 'test.txt' in os.listdir(sample_buildout) False
We can run more than one commands:
>>> 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
We can also run some python code:
>>> cfg = """
... [buildout]
... parts = py py2
...
... [py]
... recipe = collective.recipe.cmd:py
... on_install=true
... cmds=
... >>> import os
... >>> 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 = collective.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)
Ok, so now we run it:
>>> print(system(buildout)) Uninstalling cmds. Running uninstall recipe. Installing py. ['.installed.cfg', 'bin', 'buildout.cfg', 'develop-eggs', 'eggs', 'parts'] ['bin', 'buildout.cfg', 'develop-eggs', 'eggs', 'parts'] Installing py2. True...
If the shell script generated from the commands returns a non-zero exit/status code then an exception is raised and buildout fails:
>>> cfg = """ ... [buildout] ... parts = cmds ... ... [cmds] ... recipe = collective.recipe.cmd ... on_install=true ... cmds= exit 23 ... """ >>> write(sample_buildout, 'buildout.cfg', cfg) >>> print(system(buildout)) Uninstalling py2. Uninstalling py. Installing cmds... ...subprocess.CalledProcessError: Command 'sh .../run' returned non-zero exit status 23.
Contributors
Gael Pasgrimaud
Lorenzo Gil Sanchez
Maik Röder
Josip Delić
Tibor Szakmány (szakitibi), Contributor
Changelog
1.0.0 (2026-08-13)
Drop support for Python 2 and Python 3 versions older then 3.10. [szakitibi]
Configure with zope.meta. [szakitibi]
Switch to PEP 420 native namespace packages. [szakitibi]
0.11 (2015-06-06)
Add support for Python 3.2 and PyPy3.
Add support for testing with tox.
Fix compatibility with zope.testing 4.2.0.
Add version and implementation trove classifiers.
0.10 (2015-02-25)
Fixed PyPy compatibility. [hathawsh]
0.9 (2014-10-04)
Python3. [jod]
0.8 (2013-11-05)
Fix package distribution. [hvelarde]
0.7 (2013-11-04)
Fail if the script generated from cmds returns with a non-zero exit/status code. [rpatterson]
Remove GPL remnants. [rpatterson]
0.6 (2011-11-28)
relicense under BSD as agreed with gawel [jodok]
0.5 (2010-02-03)
dont run commands with on_install/on_update are set to false. Thanks to Sean Kelly for bug report [gawel]
0.4 (2009-08-18)
Add support for an ‘uninstall_cmds’ option to execute commands during the uninstall Buildout phase. [lgs, mroeder]
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]
Metadata
Release files for collective.recipe.cmd 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| collective_recipe_cmd-1.0.0.tar.gz | 10.1 kB | Without provenance | Details for collective_recipe_cmd-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| collective_recipe_cmd-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for collective_recipe_cmd-1.0.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / collective_recipe_cmd-1.0.0.tar.gz
| Download URL | collective_recipe_cmd-1.0.0.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f38c84420650d5483c17963b9f3d9f45b0a2a295569f04166d07d59b392e74
|
|
BLAKE2b-256 checksum How to use checksums |
b00e463d5e3ac3e7729a5ac38329591559ed78f03d80c0800ffef9b9ba3009d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / collective_recipe_cmd-1.0.0-py3-none-any.whl
| Download URL | collective_recipe_cmd-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b432a49ed39818042051bfd02a2097177b38df06f01354715ae0ed7b7882f361
|
|
BLAKE2b-256 checksum How to use checksums |
d8e9cb991bf5f982d479e5cf90e989fd3dfea66ccd1ef134fec685f35662e768
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for collective.recipe.cmd 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.