def conn(self): """Return a new user in a read-annotate group.""" group = self.new_group(perms='rwra--') user = self.new_client_and_user(group=group) gateway = BlitzGateway(client_obj=user[0]) # Refresh the session context gateway.getEventContext() return gateway
def get_connection(user, group_id=None): """Get a BlitzGateway connection for the given user's client.""" connection = BlitzGateway(client_obj=user[0]) # Refresh the session context connection.getEventContext() if group_id is not None: connection.SERVICE_OPTS.setOmeroGroup(group_id) return connection
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 "Other Members of current group:" for exp in conn.listColleagues(): print " ID:", exp.getId(), exp.getOmeName(), " Name:", exp.getFullName() print "Owner of:" for g in conn.listOwnedGroups(): print " ID:", g.getName(), " Name:", g.getId() # New in OMERO 5 print "Admins:" for exp in conn.getAdministrators(): print " ID:", exp.getId(), exp.getOmeName(), " Name:", exp.getFullName() # The 'context' of our current session ctx = conn.getEventContext() # print ctx # for more info # Close connection: # ================================================================= # When you are done, close the session to free up server resources. conn._closeSession()
user = conn.getUser() print "Current user:"******" ID:", user.getId() print " Username:"******" 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 "Other Members of current group:" for exp in conn.listColleagues(): print " ID:", exp.getId(), exp.getOmeName( ), " Name:", exp.getFullName() print "Owner of:" for g in conn.listOwnedGroups(): print " ID:", g.getName(), " Name:", g.getId() # The 'context' of our current session ctx = conn.getEventContext() # print ctx # for more info # Close connection: # ================================================================= # When you're done, close the session to free up server resources. conn._closeSession()
print("""%s%s:%s Name:"%s" (owner=%s)""" % (" " * indent, obj.OMERO_CLASS, obj.getId(), obj.getName(), obj.getOwnerOmeName())) # List all Projects owned by the user currently logged in # ======================================================= # By default this returns Projects from all owners across # all groups. We can filter by group and owner using the # optional opts dict (new in 5.3.0) # We also order by name and use 'limit' and 'offset', # to load the first 5 Projects print("\nList Projects:") print("=" * 50) my_exp_id = conn.getUser().getId() default_group_id = conn.getEventContext().groupId for project in conn.getObjects("Project", opts={ 'owner': my_exp_id, 'group': default_group_id, 'order_by': 'lower(obj.name)', 'limit': 5, 'offset': 0 }): print_obj(project) assert project.getDetails().getOwner().id == my_exp_id # We can get Datasets with listChildren, since we have the Project already. # Or conn.getObjects("Dataset", opts={'project', id}) if we have Project ID for dataset in project.listChildren(): print_obj(dataset, 2) for image in dataset.listChildren():