Created
September 22, 2011 23:31
-
-
Save will-moore/1236347 to your computer and use it in GitHub Desktop.
Tutorial sample file for OMERO training workshop
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
# This script shows a simple connection to OMERO, printing details of the connection. | |
# NB: You will need to edit the 'host', 'user' and 'password' fields before running. | |
# Connect to the Python Blitz Gateway | |
# See OmeroPy/Gateway for more info | |
# import the libraries we need | |
from omero.gateway import BlitzGateway | |
from omero.rtypes import * | |
# use these login details: | |
host = 'localhost' | |
user = 'will' | |
password = 'ome' | |
# create a connection | |
conn = BlitzGateway(user, password, host=host, port=4064) | |
conn.connect() | |
# Current session details | |
# By default, you will have logged into your 'current' group in OMERO. This can be changed by | |
# switching group in the OMERO insight or web clients. | |
user = conn.getUser() | |
print "Current user:" | |
print " ID:", user.getId() | |
print " Username:", user.getName() | |
print " Full Name:", user.getFullName() | |
print "Member of:" | |
for g in conn.getGroupsMemberOf(): | |
print " ID:", g.getName(), " Name:", g.getId() | |
group = conn.getGroupFromContext() | |
print "Current group: ", group.getName() | |
print "Current group Members:" | |
for groupExpLink in group.copyGroupExperimenterMap(): | |
print " ID:", groupExpLink.child.id.val, " Username:", groupExpLink.child.omeName.val | |
# The 'context' of our current session | |
ctx = conn.getEventContext() | |
# print ctx # for more info | |
conn._closeSession() |
Blitz Gateway needs to wrap group.copyGroupExperimenterMap() etc, E.g. group.listExperimenters().
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to check what the best way is to closeSession()