Standalone client
#!/usr/bin/env python2.7
import ecflow
import time
def monitor_critical_task(ci, path_to_task):
# Query the server for any changes
if ci.news_local():
# get the incremental changes, and merge with defs stored on the Client
ci.sync_local()
# check to see if definition exists in the server
defs = ci.get_defs()
if defs == None :
exit(0) # return
# find the task we are interested in
critical_task = defs.find_abs_node(path_to_task)
if critical_task == None:
# No such task
exit(0) # return
# Check to see if task was aborted, if it was email me the job output
if critical_task.get_state() == ecflow.State.aborted:
# Get the job output
the_aborted_task_output = ci.get_file(path_to_task,'jobout')
# email(the_aborted_task_output)
exit(0)
try:
# Create the client. This will read the default environment variables
ci = ecflow.Client("localhost", "4143")
# Continually monitor the suite
while 1:
monitor_critical_task(ci, "/suite/critical_node")
# Sleep for 5 minutes.
# To avoid overloading server ensure sleep is > 60 seconds
time.sleep(300)
except RuntimeError, e:
print str(e)
Display ecFlow server content as a file system
Another example is to use an ecFlow python client to provide the server content visible like a mounted file system.
virtualenv venv . ./venv/bin/activate pip install fusepy
The following script shows that task wrappers, manual page, job, output or even node attributes may be provided as files.
Client shall be activated:
mkdir -p mnt; python ./py_fuse_ecflow.py $ECF_NODE $ECF_PORT mnt;
In this example, each node status is encoded as a three characters extension (.com for complete, .que for queued, .abo for aborted ...) and you will appreciate that suspended status is not displayed.
Standard command line utilities (find, ls, cat, ...) can be used then:
# server eod3 was mounted ls eod3/emc_41r2/thu # 01 01.att 01.que hind hind.att hind.que verify verify.att verify.com cat eod3/emc_41r2/main/18bc/sv/getini.ecf cat eod3/emc_41r2/main/18bc/sv/getini.man cat eod3/emc_41r2/main/18bc/sv/getini.out kdirstat eod3/emc_41r2/main/ find eod3 -name "*.abo"