<div class="section" id="native-python-tasks">
<p>Here is an example of a script as a local native python task</p>
<ul class="simple">
<li>definition file:</li>
</ul>
<div class="highlight-python"><pre> task python
edit ECF_MICRO '^'
edit ECF_JOB_CMD '^ECF_JOB^ > ^ECF_JOBOUT^ 2>&1'
label info "none"
meter step -1 100 100
event 1
event 2</pre>
</div>
<ul class="simple">
<li>task wrapper:</li>
</ul>
<div class="highlight-python"><pre>#!/usr/env python
#python.ecf
^include <head.py>
^manual
one liner manual ...
^end
^comment
one liner
^end
xlabel("info", "start")
xevent("1")
for step in range(0,101):
print step
xmeter("step", step)
xevent("2")
xlabel("info", "completion")
^include <tail.py></pre>
</div>
<ul class="simple">
<li>headers:</li>
</ul>
<div class="highlight-python"><pre>#!/usr/local/bin/python
# head.py
import os, sys, signal
ECF_PORT = ^ECF_PORT:0^
XSVR = "ecflow_client --port %s --host ^ECF_NODE:0^ --" % ECF_PORT
pid = os.getpid()
def xinit():
os.system(XSVR + "init %s"%pid)
def xabort():
os.system(XSVR + "abort %s"%pid)
def xcomplete():
os.system(XSVR + "complete")
def SigHandler(signum, frame):
xabort(); sys.exit(0)
signal.signal (signal.SIGINT, SigHandler); # ...
os.environ['ECF_PORT'] = "^ECF_PORT:0^"
os.environ['ECF_NAME'] = "^ECF_NAME:0^"
os.environ['ECF_NODE'] = "^ECF_NODE:0^"
os.environ['ECF_PASS'] = "^ECF_PASS:0^"
def xmeter(name, step):
os.system(XSVR + "meter %s %s"%(name,step))
def xevent(name):
os.system(XSVR + "event %s"%name)
def xlabel(name, info):
os.system(XSVR + "label %s %s"%(name,info))
signal.signal (signal.SIGHUP, SigHandler)
signal.signal (signal.SIGQUIT, SigHandler)
signal.signal (signal.SIGILL, SigHandler)
signal.signal (signal.SIGTRAP, SigHandler)
signal.signal (signal.SIGIOT, SigHandler)
signal.signal (signal.SIGBUS, SigHandler)
signal.signal (signal.SIGFPE, SigHandler)
signal.signal (signal.SIGUSR1, SigHandler)
signal.signal (signal.SIGUSR2, SigHandler)
signal.signal (signal.SIGPIPE, SigHandler)
signal.signal (signal.SIGTERM, SigHandler)
signal.signal (signal.SIGXCPU, SigHandler)
signal.signal (signal.SIGPWR, SigHandler)
print 'start'
xinit()
</pre>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># tail.py</span>
<span class="n">xcomplete</span><span class="p">()</span>
</pre></div>
</div>
</div>
|