File: native_python_task.rst

package info (click to toggle)
ecflow 5.15.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,868 kB
  • sloc: cpp: 269,341; python: 22,756; sh: 3,609; perl: 770; xml: 333; f90: 204; ansic: 141; makefile: 70
file content (28 lines) | stat: -rw-r--r-- 1,426 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

Native Python tasks
*******************

Here is an example of a script as a local native Python task: This example shows that we can still take advantage of pre-processing and variable substitution. This will work on the manual and comments section, these will also be pre-processed.

There are several ways of doing this. The following are examples.

* There are two ways of accessing the ecFlow child commands (init, event, meter, label, abort, complete). We can either call the child commands directly using ecFlow extension, or we can call system command to access :term:`ecflow_client`. The following examples will use the ecFlow Python extension. This requires that the PYTHONPATH is set to the directory where ecflow.so extension was installed.

* definition file: The default ECF_MICRO is %, this may interfere with your Python scripts. In this case you either redefine it, in the task definition or directly in the Python script. 

    .. literalinclude:: src/python.def
        :language: shell

    Notice that the ECF_JOB_CMD calls Python. This allows us to change the Python version, within the viewer. Alternatively it can be omitted, providing we add "#!/usr/bin/env python" as th first line of our Python script.

* headers:

    .. literalinclude:: src/head.py
        :language: python

    .. literalinclude:: src/tail.py
        :language: python

* task wrapper:

    .. literalinclude:: src/python.ecf