We're Hiring!

OMERO and Git

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.

Re: OMERO and Git

Postby bhcho » Thu Jul 28, 2011 7:11 pm

that text file contains some information that our other python code will open/load it.
the file ending is tentatively ".opt"

let me show you a snippet of our python code (this code should live in OMERO_HOME/lib/python).

Code: Select all
def loadAdminInfo():
    # extract the information from a configuration file or something
    # load the configuration file path
    env = os.environ
    try:
        OMERO_HOME = env['OMERO_HOME']
    except:
        return "nope", "nope"

    # load the administrator's account info
    filename = OMERO_HOME + '/lib/python/OMERO_PSLID_config.opt';
    f=open(filename, 'rb')
    lines = f.readlines()



So if we copy the file, 'OMERO_PSLID_config.opt', to resources/ directory in the git, does it automatically go to OMERO_HOME/lib/python/ (when you generate OMERO 4.2.1. version from the git clone)? and can we open the file by the above code?

bk

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

Re: OMERO and Git

Postby jmoore » Thu Jul 28, 2011 8:28 pm

A better option for a file like that is most likely under etc/, which is copied entirely to the builds etc/ directory.

Depending on what the file looks like, however, you could use the bin/omero config facilities by doing something like:
Code: Select all
from omero.config import ConfigXml
cfg = ConfigXml()
cfg["my.property"] = "foo"
print cfg["my.property"]
cfg.close() # Saves my.property


End users would then only have one place they'd need to configure things.

Cheers,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: OMERO and Git

Postby bhcho » Fri Aug 12, 2011 8:30 pm

Hi Josh,

I got the following error for ConfigXml.
Code: Select all
In [4]: cfg = ConfigXml()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/afs/cs.cmu.edu/user/bhcho/<ipython console> in <module>()

TypeError: __init__() takes at least 2 arguments (1 given)


is this because I'm using 4.2.1?

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

Re: OMERO and Git

Postby jmoore » Sat Aug 13, 2011 12:11 pm

Hi BK,

no it's because the ConfigXml constructor has a required argument: "filename", which should point to your etc/grid/config.xml file.

~J.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: OMERO and Git

Postby bhcho » Wed Nov 02, 2011 8:15 pm

Hi,

Could you tell me the java version of configxml methods?
Code: Select all
from omero.config import ConfigXml
cfg = ConfigXml()
cfg["my.property"] = "foo"
print cfg["my.property"]
cfg.close() # Saves my.property


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

Re: OMERO and Git

Postby jmoore » Thu Nov 03, 2011 7:21 am

Hi BK,

there are none. omero.confg is Python-only at the moment.

~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Previous

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests