Skip to main content

ZC Buildout recipe to execute a commande line

Project description

This recipe is used to run one or more command lines

We need some buildout vars:

>>> import os
>>> join = os.path.join
>>> data_dir = join(test_dir, 'data')
>>> parts_dir = join(data_dir, 'parts')
>>> buildout = {'instance': {'location': test_dir},
...             'buildout': {'directory': test_dir,
...             'parts-directory': test_dir}}
>>> name = 'cmds'

Ok, so now we can touch a file in data_dir:

>>> test_file = join(data_dir, 'test.txt')

>>> options = {'cmds': 'touch %s' % test_file}

>>> from iw.recipe.cmd import Recipe
>>> recipe = Recipe(buildout, name, options)
>>> path = recipe.install()
>>> 'test.txt' in os.listdir(data_dir)
True

And remove it:

>>> options = {'cmds': 'rm -f %s' % test_file}
>>> recipe = Recipe(buildout, name, options)
>>> path = recipe.install()
>>> 'test.txt' in os.listdir(data_dir)
False

We can run more than one commands:

>>> cmds = '''
... touch %s
... rm -f %s
... ''' % (test_file, test_file)

>>> recipe = Recipe(buildout, name, options)
>>> path = recipe.install()
>>> 'test.txt' in os.listdir(data_dir)
False

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

iw.recipe.cmd-0.1dev_r6491-py2.4.egg (8.2 kB view details)

Uploaded Egg

File details

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

File metadata

File hashes

Hashes for iw.recipe.cmd-0.1dev_r6491-py2.4.egg
Algorithm Hash digest
SHA256 912bcaa8898f7924194e2fda0643e2824329f6c7aafa58b510e9ae6866249478
MD5 acec964eb8d8ea33ba455bfdb030e866
BLAKE2b-256 11e278dc8d87f7809648a4428c33eeac65d543ee018f74225e0928808a936871

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