<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=""><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’ve run into a similar problem as last time. I’ve written a script that will upload an image to a remote OMERO server, but only from the python command line, and not from within a script running in a local OMERO. As before, the script will work from the command line or from with OMERO when transferring the image to the local OMERO server. When I try to import an image on the remote server, I get the following error: </div><div class="">2017-11-09 15:16:30,696 1591 [ main] INFO ome.formats.OMEROMetadataStoreClient - Attempting initial SSL connection to <a href="http://demo.openmicroscopy.org:4064/" class="">demo.openmicroscopy.org:4064</a><br class="">2017-11-09 15:16:31,435 2330 [ main] ERROR formats.importer.cli.CommandLineImporter - Error during import process.<br class="">Glacier2.PermissionDeniedException: null</div><div class=""><br class=""></div><div class="">The code, and full error output are below. </div><div class="">I’ve also put it into a different script on gist that demonstrates the error by running it from within OMERO as a script. <a href="https://gist.github.com/eilidh-t/e763dab7d4f3515cc85b0b6ddfb8d9f4" class="">https://gist.github.com/eilidh-t/e763dab7d4f3515cc85b0b6ddfb8d9f4</a></div><div class=""><br class=""></div><div class="">Thanks for your help with this,</div><div class="">Eilidh</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">sendImageRemotely.py</div><div class="">================</div><div class=""><pre style="background-color: rgb(255, 255, 255); font-family: Menlo; font-size: 9pt;" class=""><span style="color:#000080;font-weight:bold;" class="">import </span>omero<br class=""><span style="color:#000080;font-weight:bold;" class="">from </span>omero.gateway <span style="color:#000080;font-weight:bold;" class="">import </span>BlitzGateway<br class=""><span style="color:#000080;font-weight:bold;" class="">from </span>path <span style="color:#000080;font-weight:bold;" class="">import </span>path<br class=""><span style="color:#000080;font-weight:bold;" class="">import </span>sys<br class=""><span style="color:#000080;font-weight:bold;" class="">import </span>subprocess<br class=""><span style="color:#000080;font-weight:bold;" class="">import </span>os<br class=""><br class="">file_loc = <span style="color:#008000;font-weight:bold;" class="">"/Users/eilidhtroup/omero/ManagedRepository/root_0/2017-10/06/" </span>\<br class=""> <span style="color:#008000;font-weight:bold;" class="">"16-21-46.945/antibiotic_plate.jpg"<br class=""></span>omero_server = <span style="color:#008000;font-weight:bold;" class="">"/Users/eilidhtroup/Documents/SynthSysDataManagement/omero/" </span>\<br class=""> <span style="color:#008000;font-weight:bold;" class="">"omeroServer/OMERO.server"<br class=""></span><span style="color:#008000;font-weight:bold;" class=""><br class=""></span><span style="color:#808080;font-style:italic;" class=""># remote<br class=""></span>username = <span style="color:#008000;font-weight:bold;" class="">""<br class=""></span>password = <span style="color:#008000;font-weight:bold;" class="">""<br class=""></span>remote_host = <span style="color:#008000;font-weight:bold;" class="">'<a href="http://demo.openmicroscopy.org/" class="">demo.openmicroscopy.org</a>'<br class=""></span>remote_port = <span style="color:#0000ff;" class="">4064<br class=""></span><span style="color:#0000ff;" class=""><br class=""></span><span style="color:#808080;font-style:italic;" class=""># connect to remote omero<br class=""></span>c = omero.client(<span style="color:#660099;" class="">host</span>=remote_host, <span style="color:#660099;" class="">port</span>=remote_port, <span style="color:#660099;" class="">args</span>=[<span style="color:#008000;font-weight:bold;" class="">"--Ice.Config=/dev/null"</span>])<br class="">c.createSession(username, password)<br class="">key = c.getSessionId()<br class=""><br class=""><span style="color:#808080;font-style:italic;" class=""># transfer image to remote omero<br class=""></span>args = [sys.executable]<br class="">args.append(<span style="color:#000080;" class="">str</span>(path(<span style="color:#008000;font-weight:bold;" class="">"."</span>) / <span style="color:#008000;font-weight:bold;" class="">"bin" </span>/ <span style="color:#008000;font-weight:bold;" class="">"omero"</span>))<br class="">args.extend([<span style="color:#008000;font-weight:bold;" class="">"-s"</span>, remote_host, <span style="color:#008000;font-weight:bold;" class="">"-k"</span>, key, <span style="color:#008000;font-weight:bold;" class="">"-p"</span>, <span style="color:#000080;" class="">str</span>(remote_port), <span style="color:#008000;font-weight:bold;" class="">"import"</span>])<br class="">args.append(file_loc)<br class=""><br class=""><span style="color:#000080;font-weight:bold;" class="">print </span><span style="color:#008000;font-weight:bold;" class="">"args are"<br class=""></span><span style="color:#000080;font-weight:bold;" class="">print </span>args<br class=""><br class=""><span style="color:#808080;font-style:italic;" class=""># omero_server = os.environ.get('OMERO_SERVER'): # doesn't work from omero script, only from command line.<br class=""></span><span style="color:#808080;font-style:italic;" class=""><br class=""></span><span style="color:#808080;font-style:italic;" class=""># </span><span style="color:#0073bf;font-weight:bold;font-style:italic;" class="">TODO could get omero_dist as done in def omerodistdir(cls):<br class=""></span><span style="color:#808080;font-style:italic;" class=""># from <a href="https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroPy/src/omero/testlib/__init__.py#L277" class="">https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tools/OmeroPy/src/omero/testlib/__init__.py#L277</a><br class=""></span>popen = subprocess.Popen(args, <span style="color:#808080;font-style:italic;" class="">#cwd=str(self.omero_dist),<br class=""></span><span style="color:#808080;font-style:italic;" class=""> </span><span style="color:#660099;" class="">cwd</span>=omero_server,<br class=""> <span style="color:#660099;" class="">stdout</span>=subprocess.PIPE,<br class=""> <span style="color:#660099;" class="">stderr</span>=subprocess.PIPE)<br class="">out, err = popen.communicate()<br class="">rc = popen.wait()<br class=""><span style="color:#000080;font-weight:bold;" class="">if </span>rc != <span style="color:#0000ff;" class="">0</span>:<br class=""> <span style="color:#000080;font-weight:bold;" class="">raise </span><span style="color:#000080;" class="">Exception</span>(<span style="color:#008000;font-weight:bold;" class="">"import failed: [%r] %s</span><span style="color:#000080;font-weight:bold;" class="">\n</span><span style="color:#008000;font-weight:bold;" class="">%s" </span>% (args, rc, err))<br class="">pix_ids = []<br class=""><span style="color:#000080;font-weight:bold;" class="">print </span><span style="color:#008000;font-weight:bold;" class="">"Output"<br class=""></span><span style="color:#000080;font-weight:bold;" class="">for </span>x <span style="color:#000080;font-weight:bold;" class="">in </span>out.split(<span style="color:#008000;font-weight:bold;" class="">"</span><span style="color:#000080;font-weight:bold;" class="">\n</span><span style="color:#008000;font-weight:bold;" class="">"</span>):<br class=""> <span style="color:#000080;font-weight:bold;" class="">print </span>x<br class=""><br class=""><span style="color:#000080;font-weight:bold;" class="">try</span>:<br class=""> remote_conn = BlitzGateway(<span style="color:#660099;" class="">client_obj</span>=c)<br class=""> <span style="color:#000080;font-weight:bold;" class="">for </span>p <span style="color:#000080;font-weight:bold;" class="">in </span>remote_conn.getObjects(<span style="color:#008000;font-weight:bold;" class="">"Project"</span>):<br class=""> <span style="color:#000080;font-weight:bold;" class="">print </span>p.id, p.name<br class=""><br class=""><span style="color:#000080;font-weight:bold;" class="">finally</span>:<br class=""> c.closeSession()<br class=""> remote_conn.close()</pre></div><div class="">================</div><div class=""><br class=""></div><div class="">> python sendImageRemotely.py <br class="">args are<br class="">['/Users/eilidhtroup/Virtual/omero/bin/python', './bin/omero', '-s', '<a href="http://demo.openmicroscopy.org/" class="">demo.openmicroscopy.org</a>', '-k', '4b8c9563-2048-4f52-911e-f50e82fab52d', '-p', '4064', 'import', '/Users/eilidhtroup/omero/ManagedRepository/root_0/2017-10/06/16-21-46.945/antibiotic_plate.jpg']<br class="">Output<br class="">Image:7999<br class=""><br class="">451 remote project<br class="">378 Project1</div><div class=""><br class=""></div><div class="">================</div><div class=""><br class=""></div><div class="">>bin/omero script launch 902<br class="">Using session eabef10d-8c5d-4b54-a7f2-1a90b354df75 (root@localhost:4064). Idle timeout: 10 min. Current group: system<br class="">ValidationException: Can't find params for 902!<br class="">stdout is in file 904:<br class="">---------------------------------<br class="">args are<br class="">['/Users/eilidhtroup/Virtual/omero/bin/python', './bin/omero', '-s', '<a href="http://demo.openmicroscopy.org/" class="">demo.openmicroscopy.org</a>', '-k', '5776f0ec-fabf-4a03-b061-85eeac9823c9', '-p', '4064', 'import', '/Users/eilidhtroup/omero/ManagedRepository/root_0/2017-10/06/16-21-46.945/antibiotic_plate.jpg']<br class=""><br class="">---------------------------------<br class="">stderr is in file 905:<br class="">---------------------------------<br class="">Traceback (most recent call last):<br class=""> File "./script", line 44, in <module><br class=""> raise Exception("import failed: [%r] %s\n%s" % (args, rc, err))<br class="">Exception: import failed: [['/Users/eilidhtroup/Virtual/omero/bin/python', './bin/omero', '-s', '<a href="http://demo.openmicroscopy.org/" class="">demo.openmicroscopy.org</a>', '-k', '5776f0ec-fabf-4a03-b061-85eeac9823c9', '-p', '4064', 'import', '/Users/eilidhtroup/omero/ManagedRepository/root_0/2017-10/06/16-21-46.945/antibiotic_plate.jpg']] 2<br class="">Joined session 5776f0ec-fabf-4a03-b061-85eeac9823c9 (<a href="mailto:etroup@demo.openmicroscopy.org" class="">etroup@demo.openmicroscopy.org</a>:4064). Idle timeout: 10 min. Current group: My Data<br class="">2017-11-09 15:16:29,477 372 [ main] INFO ome.formats.importer.ImportConfig - OMERO Version: 5.4.0-ice36-b74<br class="">2017-11-09 15:16:29,504 399 [ main] INFO ome.formats.importer.ImportConfig - Bioformats version: 5.7.1 revision: 4d44544dc5ab8824fd3d15e74211ae97aac7e3c0 date: 20 September 2017<br class="">2017-11-09 15:16:29,549 444 [ main] INFO formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO<br class="">2017-11-09 15:16:30,128 1023 [ main] INFO ome.formats.importer.ImportCandidates - Depth: 4 Metadata Level: MINIMUM<br class="">2017-11-09 15:16:30,400 1295 [ main] INFO ome.formats.importer.ImportCandidates - 1 file(s) parsed into 1 group(s) with 1 call(s) to setId in 268ms. (272ms total) [0 unknowns]<br class="">2017-11-09 15:16:30,696 1591 [ main] INFO ome.formats.OMEROMetadataStoreClient - Attempting initial SSL connection to <a href="http://demo.openmicroscopy.org:4064/" class="">demo.openmicroscopy.org:4064</a><br class="">2017-11-09 15:16:31,435 2330 [ main] ERROR formats.importer.cli.CommandLineImporter - Error during import process.<br class="">Glacier2.PermissionDeniedException: null<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_20]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_20]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_20]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at java.lang.reflect.Constructor.newInstance(Constructor.java:408) ~[na:1.8.0_20]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at java.lang.Class.newInstance(Class.java:433) ~[na:1.8.0_20]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at IceInternal.BasicStream.createUserException(BasicStream.java:2779) ~[ice.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at IceInternal.BasicStream.access$300(BasicStream.java:14) ~[ice.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at IceInternal.BasicStream$EncapsDecoder10.throwException(BasicStream.java:3298) ~[ice.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at IceInternal.BasicStream.throwException(BasicStream.java:2291) ~[ice.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at IceInternal.OutgoingAsync.throwUserException(OutgoingAsync.java:399) ~[ice.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at Glacier2.RouterPrxHelper.end_createSession(RouterPrxHelper.java:178) ~[glacier2.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at Glacier2.RouterPrxHelper.createSession(RouterPrxHelper.java:49) ~[glacier2.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at Glacier2.RouterPrxHelper.createSession(RouterPrxHelper.java:41) ~[glacier2.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at omero.client.createSession(client.java:724) ~[blitz.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at omero.client.joinSession(client.java:658) ~[blitz.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at ome.formats.OMEROMetadataStoreClient.initialize(OMEROMetadataStoreClient.java:700) ~[blitz.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at ome.formats.importer.ImportConfig.createStore(ImportConfig.java:378) ~[blitz.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at ome.formats.importer.cli.CommandLineImporter.<init>(CommandLineImporter.java:169) ~[blitz.jar:na]<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>at ome.formats.importer.cli.CommandLineImporter.main(CommandLineImporter.java:955) ~[blitz.jar:na]<br class=""><br class="">!! 11/09/17 15:16:31.980 error: communicator not destroyed during global destruction.<br class="">---------------------------------<br class=""><br class=""><br class=""></div></div></body></html>