<div id="understanding-the-client"> <span id="index-0"></span><span id="id1"></span> <p>All communication with the <a href="/wiki/display/ECFLOW/Glossary#term-ecflow-server"><em >ecflow_server</em></a> is done with <a href="/wiki/display/ECFLOW/Glossary#term-ecflow-client"><em >ecflow_client</em></a></p> <div > <div >For any communication with the server, the client needs to know the machine</div> <div >where the server is running, and the port on the server. There can be multiple</div> <div >server’s running on the same machine, hence the port number is important.</div> </div> <p>This tutorial will show examples of using the client at the shell and in a python script.</p> <div id="client-shell-interface"> <h2>Client Shell Interface<a href="#client-shell-interface" title="Permalink to this headline">¶</a></h2> <p>For a full list of available commands type:</p> <div ><pre>> ecflow_client --help</pre> </div> <div > <div >The <a href="/wiki/display/ECFLOW/Glossary#term-ecflow-client"><em >ecflow_client</em></a> uses the following method of determining the <strong>host</strong> and <strong>port</strong></div> </div> <ul> <li><p >Default host and port is <strong>localhost</strong>:<strong>3141</strong></p> </li> <li><p >These defaults are overridden by ECF_NODE and ECF_PORT environment variables</p> </li> <li><div > <div >This can be further overridden by using –port and –host options</div> <div >and can be used for any of shell level command shown with –help option.</div> <div >For example to ping a server on the command line we can use:</div> </div> <div ><pre>> ecflow_client --ping --host=machineX --port=4141</pre> </div> </li> </ul> </div> <div id="client-python-interface"> <h2>Client Python Interface<a href="#client-python-interface" title="Permalink to this headline">¶</a></h2> <div > <div >The functionality provided by <a href="/wiki/display/ECFLOW/Glossary#term-ecflow-client"><em >ecflow_client</em></a> is also available via the <a href="/wiki/display/ECFLOW/ecFlow+Python+Api#python-api"><em>ecFlow Python Api</em></a>.</div> <div >Please see <tt ><span >ecflow.Client</span></tt>.</div> </div> <div > <div >The python interface uses the same algorithm for determining the host and port,</div> <div >and allows the host and port to be set explicitly. See class <tt ><span >ecflow.Client</span></tt></div> <div >This is shown by the following python example:</div> </div> <div ><div ><pre><span >import</span> <span >ecflow</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 >"oetzi"</span><span >,</span><span >"3444"</span><span >)</span> <span ># Explicitly set host and port</span> <span >try</span><span >:</span> <span >ci</span><span >.</span><span >ping</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> <p>What to do:</p> <div > <div >If your <a href="/wiki/display/ECFLOW/Glossary#term-ecflow-server"><em >ecflow_server</em></a> was started with <strong>ecf_start.sh</strong> and wish to use the shell</div> <div >interface, then set ECF_NODE and ECF_PORT environment variables</div> </div> </div> </div> |