[ome-devel] cli.invoke() closes session
Eilidh Troup
e.troup at epcc.ed.ac.uk
Fri Jan 26 17:36:59 GMT 2018
Thank you Josh, that works for me.
> On 25 Jan 2018, at 17:11, Josh Moore <josh at glencoesoftware.com <mailto:josh at glencoesoftware.com>> wrote:
>
> On Thu, Jan 25, 2018 at 5:51 PM, Eilidh Troup <e.troup at epcc.ed.ac.uk <mailto:e.troup at epcc.ed.ac.uk>> wrote:
>> Hi,
>
> Hi Eilidh,
>
>
>> 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?
>
> Interesting. I was thinking that you needed a single line addition:
>
> sf = c.createSession(username,password)
> sf.detachOnDestroy() # i.e. don't destroy my session
> cli = omero.cli.CLI()
>
> but that's not working for me either, which I consider a bug. You can
> workaround by using a lower-level command, onecmd, but you'll need to
> take responsibility for the closing yourself:
>
> try:
> # ....
> cli.onecmd(["import", "a.fake"])
> cli.onecmd(["import", "b.fake"])
> finally:
> cli.close()
>
>
> Regards,
> ~Josh
>
>
>> Thanks,
>> Eilidh
>>
>>
>> import omero
>> import omero.cli
>> REMOTE_HOST = 'demo.openmicroscopy.org <http://demo.openmicroscopy.org/>'
>> REMOTE_PORT = 4064
>> username = ""
>> password = ""
>> c = omero.client(host=REMOTE_HOST,
>> port=REMOTE_PORT,args=["--Ice.Config=/dev/null", "--omero.debug=1"])
>> c.createSession(username,password)
>> cli = omero.cli.CLI()
>> cli.loadplugins()
>> cli.set_client(c)
>> del os.environ["ICE_CONFIG"]
>> file_loc =
>> "/Users/eilidhtroup/OMERO/ManagedRepository/root_0/2017-12/05/20-55-11.910/antibiotic_plate.jpg"
>> cli.invoke(["import", file_loc]) #works - remote
>> cli.invoke(["import", file_loc]) # doesn't work - will import into local
>> session if one exists.
>> c.createSession(username,password)
>> cli.set_client(c)
>> cli.invoke(["import", file_loc]) #works again -remote.
> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk <mailto:ome-devel at lists.openmicroscopy.org.uk>
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel <http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20180126/2dea7603/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20180126/2dea7603/attachment.ksh>
More information about the ome-devel
mailing list