Last active
December 29, 2015 17:59
-
-
Save dpwrussell/7707870 to your computer and use it in GitHub Desktop.
OMERO basic setup for quick tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
omero_details.cfg | |
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import ConfigParser | |
import omero | |
from omero.gateway import BlitzGateway | |
# from copy import deepcopy | |
# OMERO Detail Config | |
omero_details = 'omero_details.cfg' | |
config = ConfigParser.RawConfigParser() | |
config.read(omero_details) | |
HOST = config.get('OMERODetails', 'host') | |
PORT = config.getint('OMERODetails', 'port') | |
USERNAME = config.get('OMERODetails', 'username') | |
PASSWORD = config.get('OMERODetails', 'password') | |
conn = BlitzGateway(USERNAME, PASSWORD, host=HOST, port=PORT) | |
connected = conn.connect() | |
if not connected: | |
import sys | |
sys.stderr.write("Error: Connection not available, please check your user name and password.\n") | |
sys.exit(1) | |
# Set the desired group context | |
params = omero.sys.ParametersI() | |
conn.SERVICE_OPTS.setOmeroGroup(-1) | |
# Or for temporary params | |
# service_opts = deepcopy(conn.SERVICE_OPTS) | |
# service_opts.setOmeroGroup(-1) | |
# Get a specific object | |
# image1 = conn.getObject('Image', omero.rtypes.rlong(1)) | |
# Get multiple objects | |
# images = conn.getObjects('Image') | |
# Run an HQL Query Projection to get a specific image | |
# q = """ | |
# select image.id | |
# from Image image | |
# where image.id=1 | |
# """ | |
# qs = conn.getQueryService() | |
# for e in qs.projection(q, params, conn.SERVICE_OPTS): | |
# print e[0].val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment