##!/usr/bin/env python
import ecf as ec
import sys
import time
class Observer(object):
""" simple ecflow watchdog class """
def __init__(self, defs, node, port, path):
super(Observer, self).__init__()
self.path = path
self.node = node
self.port = port
def process_node(self, node):
status = "%s" % node.get_dstate()
if status not in ("queued", "complete"):
print node.get_abs_node_path(), status
for kid in node.nodes:
self.process_node(kid)
def clear(self):
for n in range(0, 64, 1): print("\r\n")
def run(self):
client = ec.Client(self.node, self.port)
while 1:
client.sync_local() # get changes,
node = client.get_defs().find_abs_node(self.path)
assert node is not None
self.clear()
self.process_node(node)
time.sleep(90)
if __name__ == "__main__":
import os.path
if len(sys.argv) < 3:
node = "localhost"
port = "31415"
path = "/"
else:
node = sys.argv[1]
port = sys.argv[2]
path = sys.argv[3]
if 1: client = Observer(None, node, port, path)
else: client = ObserverHtml(None, node, port, path)
client.run() |