Ejemplo n.º 1
0
 def __init__(self):
     env = {
         "ECF_NODE": "$ECF_NODE$",
         "ECF_PASS": "******",
         "ECF_NAME": "$ECF_NAME$",
         "ECF_PORT": "$ECF_PORT$",
         "ECF_TRYNO": "$ECF_TRYNO$",
     }
     if MICRO[0] in env["ECF_PORT"]:
         self.client = None
         return
     self.client = ec.Client()
     self.client.set_child_timeout(20)
     self.client.set_host_port(env["ECF_NODE"], int(env["ECF_PORT"]))
     self.client.set_child_pid(os.getpid())
     self.client.set_child_path(env["ECF_NAME"])
     self.client.set_child_password(env["ECF_PASS"])
     self.client.set_child_try_no(int(env["ECF_TRYNO"]))
     self.report("init")
     for sig in (signal.SIGINT, signal.SIGHUP, signal.SIGQUIT,
                 signal.SIGILL, signal.SIGTRAP, signal.SIGIOT,
                 signal.SIGBUS, signal.SIGFPE, signal.SIGUSR1,
                 signal.SIGUSR2, signal.SIGPIPE, signal.SIGTERM,
                 signal.SIGXCPU, signal.SIGPWR):
         signal.signal(sig, self.signal_handler)
Ejemplo n.º 2
0
#!/usr/bin/env python2.7
""" back archive example """
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defs, Defstatus, Suite, Family, Task, Variables, Label,
                 Limit, Inlimit, Repeat, Trigger)
HOME = os.getenv("HOME") + "/ecflow_server"
NAME = "back_archiving"; FILES = HOME + "/back"; DEFS = Defs()
DEFS.add(Suite(NAME).add(
    Defstatus("suspended"),  # so that jobs do not start immediately
    Repeat(kind="day", step=1),
    Variables(ECF_HOME=HOME, ECF_INCLUDE=HOME, ECF_FILES=FILES, SLEEP=2),
    Limit("access", 2),
    [Family(kind).add(
        Repeat("DATE", 19900101, 19950712, kind="date"),
        Variables(KIND=kind),
        Task("get_old").add(Inlimit("access"), Label("info", "")),
        Task("convert").add(Trigger("get_old == complete")),
        Task("save_new").add(Trigger("convert eq complete"))
    ) for kind in ("analysis", "forecast", "climatology", "observations", "images")]))
# print(DEFS); DEFS.generate_scripts(); 
RESULT = DEFS.simulate(); print(RESULT)
CLIENT = ecflow.Client(os.getenv("ECF_HOST", "localhost"),
                       os.getenv("ECF_PORT", 2500))
CLIENT.replace("/%s" % NAME, DEFS)
Ejemplo n.º 3
0
        Variables(  # we can add multiple variables at once
            ECF_HOME=ECF_HOME,  # where job files are created by ecflow
            ECF_FILES=ECF_HOME + "/files",  # where to find script templates
            ECF_INCLUDE=ECF_HOME + "/include",  # where to find head.h tail.h
            SLEEP=2),
        create_families()))

SCRIPT_TEMPLATE = """#!/bin/bash
%include <head.h>
STEP=0
while [[ $STEP -le 240 ]] ; do
  sleep %SLEEP:1%; ecflow_client --meter step $STEP  # share progress
  msg="The date is %DATE:$(date)%. PARAM is %PARAM:% NAME is %NAME:%"
  ecflow_client --label info "$msg"
  (( STEP = STEP + 1))
done
%include <tail.h>
"""

if __name__ == '__main__':
    with open(ECF_HOME + "/files/t1.ecf", "w") as script:
        print(SCRIPT_TEMPLATE, file=script)

    HOST = os.getenv("ECF_HOST", "localhost")
    PORT = int(os.getenv("ECF_PORT", "%d" % (1500 + os.getuid())))
    CLIENT = ecflow.Client(HOST, PORT)

    NODE = "/%s/f5" % NAME  # replace top
    CLIENT.replace(NODE, DEFS)
    print("replaced node %s into" % NODE, HOST, PORT)