本文整理汇总了Python中omero.gateway.BlitzGateway.getGroupsMemberOf方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.getGroupsMemberOf方法的具体用法?Python BlitzGateway.getGroupsMemberOf怎么用?Python BlitzGateway.getGroupsMemberOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.getGroupsMemberOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect_to_omero
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getGroupsMemberOf [as 别名]
def connect_to_omero(user, password, host, port=4064):
conn = BlitzGateway(user, password, host=host, port=port)
print conn.connect()
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()
return conn
示例2: group_exists
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getGroupsMemberOf [as 别名]
def group_exists(self, user, group):
if not self.user_exists(user):
return False
else:
if group in self.known_users[user]:
print "in Group:", group
return True
try:
try:
conn = BlitzGateway(user, "ome", host='localhost')
conn.connect()
groups = conn.getGroupsMemberOf()
except:
return False
if group in [g.name for g in groups]:
print "in Group:", group
self.known_users[user].append(group)
return True
else:
print "is not in Group:", group, "- ignoring."
return False
finally:
conn.seppuku()
示例3:
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getGroupsMemberOf [as 别名]
# conn.setSecure(True) # <--------- Uncomment this
# 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 OMERO.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 "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():
示例4: Omg
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getGroupsMemberOf [as 别名]
class Omg(object):
"""
OMERO gateway that wraps Blitz gateway and CLI, intended for
scripting and interactive work.
Attributes
----------
conn : Blitz gateway connection
"""
def __init__(self, conn=None, user=None, passwd=None,
server=SERVER, port=PORT, skey=None):
"""
Requires active Blitz connection OR username plus password or sesskey
"""
if conn is None and (user is None or (passwd is None and skey is None)):
raise ValueError("Bad parameters," + self.__init__.__doc__)
if conn is not None:
if conn.isConnected():
self.conn = conn
else:
raise ValueError("Cannot initialize with closed connection!")
else:
if passwd is not None:
self.conn = BlitzGateway(user, passwd, host=server, port=port)
self.conn.connect()
else:
self.conn = BlitzGateway(user, host=server, port=port)
self.conn.connect(skey)
if self.conn.isConnected():
self._server = self.conn.host
self._port = self.conn.port
self._user = self.conn.getUser().getName()
self._key = self.conn.getSession().getUuid().getValue()
print("Connected to {0} (port {1}) as {2}, session key={3}".format(
self._server, self._port, self._user, self._key))
else:
print("Failed to open connection :-(")
def ls(self):
"""
Print groups, then projects/datasets/images for current group.
"""
print("Groups for {0}:-".format(self.conn.getUser().getName()))
for gid, gname in self._ls_groups():
print(" {0} ({1})".format(gname, str(gid)))
curr_grp = self.conn.getGroupFromContext()
gid, gname = curr_grp.getId(), curr_grp.getName()
print("\nData for current group, {0} ({1}):-".format(gname, gid))
for pid, pname in self._ls_projects():
print(" Project: {0} ({1})".format(pname, str(pid)))
for did, dname in self._ls_datasets(pid):
print(" Dataset: {0} ({1})".format(dname, str(did)))
for iid, iname in self._ls_images(did):
print(" Image: {0} ({1})".format(iname, str(iid)))
# TODO, list orphaned Datasets and Images
def _ls_groups(self):
"""list groups (id, name) this session is a member of"""
groups = self.conn.getGroupsMemberOf()
return [(group.getId(), group.getName()) for group in groups]
def _ls_projects(self):
"""list projects (id, name) in the current session group"""
projs = self.conn.listProjects(self.conn.getUserId())
return [(proj.getId(), proj.getName()) for proj in projs]
def _ls_datasets(self, proj_id):
"""list datasets (id, name) within the project id given"""
dsets = self.conn.getObject("Project", proj_id).listChildren()
return [(dset.getId(), dset.getName()) for dset in dsets]
def _ls_images(self, dset_id):
"""list images (id, name) within the dataset id given"""
imgs = self.conn.getObject("Dataset", dset_id).listChildren()
return [(img.getId(), img.getName()) for img in imgs]
def chgrp(self, group_id):
"""
Change group for this session to the group_id given.
"""
self.conn.setGroupForSession(group_id)
def get(self, im_id, get_att=True):
"""
Download the specified image as an OME-TIFF to current directory,
with attachments also downloaded to folder: img_path + '_attachments'
Return : path to downloaded image
"""
img = self.conn.getObject("Image", oid=im_id)
img_name = self._unique_name(img.getName(), im_id)
img_path = os.path.join(os.getcwd(), img_name)
img_file = open(str(img_path + ".ome.tiff"), "wb")
fsize, blockgen = img.exportOmeTiff(bufsize=65536)
for block in blockgen:
img_file.write(block)
img_file.close()
fa_type = omero.model.FileAnnotationI
attachments = [ann for ann in img.listAnnotations()
#.........这里部分代码省略.........
示例5: rint
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import getGroupsMemberOf [as 别名]
if theT is not None:
rect.theT = rint(theT)
if label is not None:
rect.textValue = wrap(label)
rect.setRoi(roi)
roi.addShape(rect)
# First, we want to make sure that every user has a tag(s) in every group
print "\n---- CREATING TAGS ----\n"
for exp in allUsers:
username = exp.getOmeName()
print username
userConn = BlitzGateway(username, "ome")
userConn.connect()
for g in userConn.getGroupsMemberOf():
if g.getName() == "user":
continue
print " ", g.getName()
userConn.SERVICE_OPTS.setOmeroGroup(g.getId())
params = omero.sys.Parameters()
params.theFilter = omero.sys.Filter()
params.theFilter.ownerId = rlong(exp.getId())
tags = list( userConn.getObjects("TagAnnotation", params=params) )
for i in range( TAG_COUNT-len(tags) ):
t = TagAnnotationI()
newTagVal = "%s_%s_TEST" % (username, g.getName())
print "creating TAG:", newTagVal
t.textValue = wrap(str(newTagVal))
userConn.getUpdateService().saveObject(t, userConn.SERVICE_OPTS)
# for t in tags: