We're Hiring!

retrieving OMERO configuration variable from python shell

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

retrieving OMERO configuration variable from python shell

Postby bhcho » Fri Apr 22, 2011 2:34 pm

Hi,


I know how to set the OMERO configuration variables.

bin/omero config set <param> <value>
bin/omero config get <param>

But I'd like to retrieve OMERO configuration variable from my python app.
can anyone help me?

BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: retrieving OMERO configuration variable from python shel

Postby cxallan » Tue Apr 26, 2011 9:06 am

That depends on your context. As the values held there regularly contain sensitive configuration values, you cannot ask for any properties unless you are in the system group. If you are, and certain values like omero.db.name, omero.db.password, etc. are completely restricted and cannot be accessed remotely, then you can use IConfig as documented:

http://hudson.openmicroscopy.org.uk/job ... onfig.html

For example:

Code: Select all
import omero
client = omero.client('localhost')
try:
    session = client.createSession('root', 'secret')
    print session.getConfigService().getConfigValue('omero.data.dir')
finally:
    client.closeSession()
cxallan
Site Admin
 
Posts: 509
Joined: Fri May 01, 2009 8:07 am

Re: retrieving OMERO configuration variable from python shel

Postby bhcho » Tue Apr 26, 2011 2:43 pm

thanks,

I could get
Code: Select all
-bash-3.2$ omero config get OMERO_HOME
/xxx/xxx/xxx/xxxx


however,
Code: Select all
config = session.getConfigService()
config.getConfigValue('OMERO_HOME')


gives errors
xxx/lib/python/omero_api_IConfig_ice.pyc in getConfigValue(self, key, _ctx)
88
89 def getConfigValue(self, key, _ctx=None):
---> 90 return _M_omero.api.IConfig._op_getConfigValue.invoke(self, ((key, ), _ctx))
91
92 def getConfigValue_async(self, _cb, key, _ctx=None):
SecurityViolation: exception ::omero::SecurityViolation
{
serverStackTrace = ome.conditions.SecurityViolation: Cannot read configuration: OMERO_HOME
at ome.logic.ConfigImpl.getConfigValue(ConfigImpl.java:222)
......
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: retrieving OMERO configuration variable from python shel

Postby cxallan » Tue Apr 26, 2011 3:34 pm

Is that user in the system group? If it is then that's a property that we don't clients to retrieve.
cxallan
Site Admin
 
Posts: 509
Joined: Fri May 01, 2009 8:07 am


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest