Skip to main content

ZC Buildout recipe to execute a commande line

Project description

What is iw.recipe.cmd ?

This recipe is used to run one or more command lines

We need a config file:

>>> 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)

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.
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 = 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)

Ok, so now we run it:

>>> 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iw.recipe.cmd-0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iw.recipe.cmd-0.2-py2.4.egg (10.5 kB view details)

Uploaded Egg

File details

Details for the file iw.recipe.cmd-0.2.tar.gz.

File metadata

  • Download URL: iw.recipe.cmd-0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for iw.recipe.cmd-0.2.tar.gz
Algorithm Hash digest
SHA256 aea18acc5912ea4fc2f2e0d6b2d9d87b7050876cfb10c32867711e9bea7cac3a
MD5 d13b953bbfd9dbd4b3648fda29b36e59
BLAKE2b-256 4049a7c51fdfbf3282ff4c3e31edc544a9259c10c52b1f404c7261f68a19a760

See more details on using hashes here.

File details

Details for the file iw.recipe.cmd-0.2-py2.4.egg.

File metadata

File hashes

Hashes for iw.recipe.cmd-0.2-py2.4.egg
Algorithm Hash digest
SHA256 93980f535cde6bf587ab0d00ab1495f84212f3e95d723ed73b04e9399c3dcd71
MD5 477bfab99430bb1be36e05702ee17c12
BLAKE2b-256 e48f501bd88801f367d7e29a8c2c72046d2058c15937af5041adc1a822d04db4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page