Skip to main content

This module implements two simple recipes to execute either a shell script (actually batch scripts under M$-Windows) or a Python script.

Both recipes take two options, install and update: both are considered as a list of statements, one per line, that will be written in a temporary file that will be executed respectively when the recipe is installed or updated. One or the other may be missing, and in such case nothing will happen for that particular step.

When the commands to execute depend on the platform, they can be specified using the options install-linux or install-win32 that have higher priority than the generic form.

Shell scripts

The metapensiero.recipe.script:shell recipe is implemented by the ShellScript class, and can be used in the following way:

[config]
recipe = metapensiero.recipe.script:shell
ini = config.ini
install = ${buildout:bin-directory}/soladmin create-config ${:ini}

As said, some time the commands to execute depend on the particular platform they are run. In such cases, you can say:

[config]
recipe = metapensiero.recipe.script:shell
ini = config.ini
install = ${buildout:bin-directory}/soladmin create-config ${:ini}
install-win32 =
   ${buildout:bin-directory}/soladmin create-config ${:ini}
   echo Configuration created!
   pause

Python scripts

The metapensiero.recipe.script:python recipe is implemented by the PythonScript class. It is somewhat more powerful because it can easily access the whole buildout configuration.

Consider the following example:

[start_script]
recipe = metapensiero.recipe.script:python
install =
  >>> import sys
  >>> from os.path import join
  >>> basedir = buildout['buildout']['directory']
  >>> bindir = buildout['buildout']['bin-directory']
  >>> script = join(basedir, 'sol.bat' if sys.platform=='win32' else 'sol.sh')
  >>> config = join(basedir, buildout['config']['ini'])
  >>> with open(script, 'w') as f:
  >>>   if sys.platform == 'win32':
  >>>     f.write('@echo off\n')
  >>>   f.write('%s %s\n' % (join(bindir, 'solserver'), config))
  >>> installed = script

As you can see, the script can access other section settings thru the buildout local variable, a dictionary that contains the whole buildout configuration. Another local variable is options, another dictionary containing the recipe settings.

The script may set the installed variable, that can be either a simple scalar string value or a sequence of strings: it will be used as the result of the recipe, which usually is the list of the files/directories installed by the recipe itself that will be deleted whenever the recipe is removed from the configuration.

Using eggs

If the Python script uses additional eggs, they can be specified with the eggs option, like in the following example:

[extjs]
recipe = metapensiero.recipe.script:python
eggs = metapensiero.extjs.desktop
install =
  >>> from metapensiero.extjs.desktop.scripts.extjs_dl import download_and_extract, URL
  >>> download_and_extract(URL)

Changes

1.2 (2014-03-08)

  • Simple test suite

  • Fix return of installed stuff in Python scripts

1.1 (2014-03-08)

  • First release on PyPI

1.0 (2014-03-08)

  • Initial version, extracted from SoLista

Metadata

Release files for metapensiero.recipe.script 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metapensiero.recipe.script 1.2
File Size Uploaded
metapensiero.recipe.script-1.2.tar.gz 6.6 kB Details

Release files / metapensiero.recipe.script-1.2.tar.gz

Download URL metapensiero.recipe.script-1.2.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
811ca69f62561d9cecb6597de169766225593bf1337cff390f95f1b966f876d8
BLAKE2b-256 checksum
How to use checksums
ede2da1a638e6b0ec28083f09d645f71cd8390552798830028b809af382da193
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2 This release

1 release file

1.1

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page