[ome-users] omero scripts: getting hostname and port to server from BaseClient
Josh Moore
josh at glencoesoftware.com
Fri Sep 19 16:50:41 BST 2014
On Sep 18, 2014, at 8:23 PM, Carnë Draug wrote:
> On 8 September 2014 10:55, Josh Moore <josh at glencoesoftware.com> wrote:
>> Hi Carnë,
Hi Carnë,
>> On Sep 4, 2014, at 7:26 PM, Carnë Draug wrote:
>
> If I understood correctly, I should not have to pass any of the session
> information (UUID or server hostname) in the arguments to invoke() when
> using omero.cli.CLI. It should be enough to set `_client' to a valid omero
> session. Is this correct?
Yup.
> This works great as long as I do it via the command-line. This tiny script
> works great:
>
...
>
> However, it fails as soon as I try to use it as an omero script. For a
> short example, the following omero script:
>
...
>
> will still fail with the following error:
>
> Usage: importer-cli [OPTION]... [path [path ...]]...
> or: importer-cli [OPTION]... -
>
> [...]
>
> Session arguments:
> Mandatory arguments for creating a session are 1- either the OMERO server
> hostname, username and password or 2- the OMERO server hostname and a
> valid session key.
>
>> P.S. while working on this script, I saw that createClient(secure=False)
>> does not work from scripts which is likely related to your issue of not
>> being able to find the hostname.
>
> I tried with "secure=True" and still did not succeed.
Sorry, Carnë. In my excitement for having found a "real" way to pass the arguments,
I forgot that import.py internally uses the "omero.host" setting, so I just propagated
your problem down the line.
We'll need to fix this so that "omero.host" can either be reliably used or is completely
unnecessary, but for the moment you can do the parsing you were looking for with:
router = copy.getProperty("Ice.Default.Router")
router = copy.getCommunicator().stringToProxy(router)
for endpoint in router.ice_getEndpoints():
host = endpoint.getInfo().host
print "Using", host
copy.ic.getProperties().setProperty("omero.host", host)
before calling cli.invoke. I now get:
* ==> Summary
* 1 file uploaded, 1 fileset created, 1 image imported, 0 errors in 0:00:07.947
*** end stderr ***
*** out parameters ***
*** done ***
Cheers,
~Josh
> Carnë
More information about the ome-users
mailing list