<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I’m writing a script to transfer images from one OMERO to another, remote OMERO. When I call cli.invoke, it works, but then closes the session, so I have to create a new session for every call of cli.invoke. Is there a better way to do this?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Eilidh</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="container" title="Hint: double-click to select code"><div class="index0 line number1 alt2"><code class="java keyword">import</code> <code class="java plain">omero </code></div><div class="line index1 alt1 number2"><code class="java keyword">import</code> <code class="java plain">omero.cli</code></div><div class="alt2 line number3 index2"><code class="java plain">REMOTE_HOST = </code><code class="java string">'<a href="http://demo.openmicroscopy.org/" class="">demo.openmicroscopy.org</a>'</code></div><div class="index3 line number4 alt1"><code class="java plain">REMOTE_PORT = </code><code class="java value">4064</code></div><div class="index3 line number4 alt1"><code class="java value">username = </code><span style="font-family: monospace;" class="">""</span></div><div class="index3 line number4 alt1"><code class="java value">password = </code><span style="font-family: monospace;" class="">""</span></div><div class="number5 line index4 alt2"><code class="java plain">c = omero.client(host=REMOTE_HOST, port=REMOTE_PORT,args=[</code><code class="java string">"--Ice.Config=/dev/null"</code><code class="java plain">, </code><code class="java string">"--omero.debug=1"</code><code class="java plain">])</code></div><div class="line number6 index5 alt1"><code class="java plain">c.createSession(</code><code class="java string">username</code><code class="java plain">,</code><code class="java plain">password)</code></div><div class="number7 alt2 line index6"><code class="java plain">cli = omero.cli.CLI()</code></div><div class="index7 line number8 alt1"><code class="java plain">cli.loadplugins()</code></div><div class="alt2 line index8 number9"><code class="java plain">cli.set_client(c)</code></div><div class="number10 line index9 alt1"><code class="java plain">del os.environ[</code><code class="java string">"ICE_CONFIG"</code><code class="java plain">]</code></div><div class="index10 line alt2 number11"><code class="java plain">file_loc = </code><code class="java string">"/Users/eilidhtroup/OMERO/ManagedRepository/root_0/2017-12/05/20-55-11.910/antibiotic_plate.jpg"</code></div><div class="line number12 index11 alt1"><code class="java plain">cli.invoke([</code><code class="java string">"import"</code><code class="java plain">, file_loc]) #works - remote</code></div><div class="index12 alt2 line number13"><code class="java plain">cli.invoke([</code><code class="java string">"import"</code><code class="java plain">, file_loc]) # doesn't work - will </code><code class="java keyword">import</code> <code class="java plain">into local session </code><code class="java keyword">if</code> <code class="java plain">one exists.</code></div><div class="number14 line index13 alt1"><code class="java plain">c.createSession(</code><code class="java string">username</code><code class="java plain">,</code><code class="java plain">password)</code></div><div class="alt2 line number15 index14"><code class="java plain">cli.set_client(c)</code></div><div class="line number16 index15 alt1"><code class="java plain">cli.invoke([</code><code class="java string">"import"</code><code class="java plain">, file_loc]) #works again -remote.</code></div><div class="line number16 index15 alt1"><br class=""></div></div></div></div></body></html>