<div id="how-can-i-access-the-path-and-task-states"> <span id="print-all-states"></span><span id="index-0"></span> <div ><div ><pre><span >import</span> <span >ecflow</span> <span ># Create the client. This will read the default environment variables</span> <span >ci</span> <span >=</span> <span >ecflow</span><span >.</span><span >Client</span><span >();</span> <span >ci</span><span >.</span><span >set_host_port</span><span >(</span><span >"localhost"</span><span >,</span> <span >"4141"</span><span >)</span> <span >try</span><span >:</span> <span ># Get the node tree suite definition as stored in the server</span> <span ># The definition is retrieved and stored on the variable 'ci'</span> <span >ci</span><span >.</span><span >sync_local</span><span >()</span> <span ># access the definition retrieved from the server</span> <span >defs</span> <span >=</span> <span >ci</span><span >.</span><span >get_defs</span><span >()</span> <span >if</span> <span >defs</span> <span >==</span> <span >None</span> <span >:</span> <span >print</span> <span >"The server has no defintion "</span> <span >exit</span><span >(</span><span >1</span><span >)</span> <span ># create a vector to hold all the tasks in the definition</span> <span >task_vec</span> <span >=</span> <span >ecflow</span><span >.</span><span >TaskVec</span><span >();</span> <span >defs</span><span >.</span><span >get_all_tasks</span><span >(</span><span >task_vec</span><span >);</span> <span ># iterate over tasks and print path and state</span> <span >for</span> <span >task</span> <span >in</span> <span >task_vec</span><span >:</span> <span >print</span> <span >task</span><span >.</span><span >get_abs_node_path</span><span >()</span> <span >+</span> <span >" "</span> <span >+</span> <span >str</span><span >(</span><span >task</span><span >.</span><span >get_state</span><span >())</span> <span >except</span> <span >RuntimeError</span><span >,</span> <span >e</span><span >:</span> <span >print</span> <span >"failed: "</span> <span >+</span> <span >str</span><span >(</span><span >e</span><span >);</span> </pre></div> </div> </div> |