Page 1 of 1

retrieving OMERO configuration variable from python shell

PostPosted: Fri Apr 22, 2011 2:34 pm
by bhcho
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

Re: retrieving OMERO configuration variable from python shel

PostPosted: Tue Apr 26, 2011 9:06 am
by cxallan
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()

Re: retrieving OMERO configuration variable from python shel

PostPosted: Tue Apr 26, 2011 2:43 pm
by bhcho
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)
......

Re: retrieving OMERO configuration variable from python shel

PostPosted: Tue Apr 26, 2011 3:34 pm
by cxallan
Is that user in the system group? If it is then that's a property that we don't clients to retrieve.