Page 1 of 1

cannot get objects in python script with OME 5

PostPosted: Wed Jul 24, 2013 7:02 am
by tom_deschamps
Hi

I just upgraded the server/client to 5.0.0 and one of my scripts is not working anymore when called from the insight client or through the web interface.
Calls like
Code: Select all
import omero.util.script_utils as scriptUtil

scriptUtil.getObjects(conn, parameterMap)

returns nothing.
Previously that was the way for me to get access to images.
Is there a way I could check that everything is working correctly, that I have the correct permissions for accessing the images?

Thanks for the help

Re: cannot get objects in python script with OME 5

PostPosted: Wed Jul 24, 2013 9:42 am
by atarkowska
Hi

What version of omero did you use before? script_util is not something recomannded anymore. We have a whole new Python API you should use.

For example getObjects works as follow:

Code: Select all
params = omero.sys.ParametersI()
params.exp(conn.getUser().getId())  # only show current user's Datasets
datasets = conn.getObjects("Dataset", params=params)


I hope it will help you
Ola

Re: cannot get objects in python script with OME 5

PostPosted: Thu Jul 25, 2013 9:07 am
by wmoore
When you say that
Code: Select all
scriptUtil.getObjects()
returned 'nothing', you mean you got the message that says "No images found" ?

You can see the code here: https://github.com/openmicroscopy/openm ... ls.py#L349

This is simply a wrapper around conn.getObjects() that gives a nice message that is used by most of our scripts.

The script should be run in the permissions/group context that you called it from the client.

Try adding these lines to your script, then check the stdout "info" from the script.

Code: Select all
print conn.getGroupFromContext().getName()
print conn.getEventContext()


Is this the group that the image is in, or can you at least see the image when logged in to that group?
Is this the group that you're running the script from?

Did you run the script from Insight or web? In insight it is possible to run a script from one 'group context' even though the image is in a different group, although if you have the image selected when you run the script then it should run the script under the correct context.

Re: cannot get objects in python script with OME 5

PostPosted: Mon Jul 29, 2013 10:42 pm
by tom_deschamps
Thanks for your reply. I'm giving a shot at it.