本文整理汇总了Python中omero.gateway.BlitzGateway.suConn方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway.suConn方法的具体用法?Python BlitzGateway.suConn怎么用?Python BlitzGateway.suConn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类omero.gateway.BlitzGateway
的用法示例。
在下文中一共展示了BlitzGateway.suConn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect_as_user
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import suConn [as 别名]
def connect_as_user(username):
"""Establish a connection to OMERO with a given user context.
To establish a connection as a specific user without knowing their
credential, a two-stage process is required: first the bsae connection is
created with an admin user, then this existing connection is switched over
to a (non-privileged) user account.
Returns the connection in the user's context.
"""
# establish the base connection with an admin account
su_conn = BlitzGateway(SU_USER, SU_PASS, host=HOST, port=PORT)
if su_conn.connect() is False:
raise RuntimeError('Connection to OMERO failed, check settings!')
# now switch to the requested user
conn = su_conn.suConn(username)
if conn.connect() is False:
raise RuntimeError('User switching in OMERO failed, check settings!')
log.debug("Successfully connected to OMERO.")
return conn
示例2: BlitzGateway
# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import suConn [as 别名]
# PASS = 'Dem0o1'
# PASS = '7777'
SU_USER = "root"
SU_PASS = "omero"
try:
from localconfig import USER, SU_USER, SU_PASS, MANAGED_REPO
except ImportError:
print "Using hard-coded configuration values!"
su_conn = BlitzGateway(SU_USER, SU_PASS, host=HOST, port=PORT)
if su_conn.connect() is False:
raise RuntimeError("Connection to OMERO failed, check settings!")
conn = su_conn.suConn(USER)
if conn.connect() is False:
raise RuntimeError("User switching in OMERO failed, check settings!")
su_conn = BlitzGateway(SU_USER, SU_PASS, host=HOST, port=PORT)
su_conn.connect()
conn = su_conn.suConn(USER)
conn.connect()
# projs = [ x for x in conn.listProjects() ]
projs = [x for x in conn.listProjects(eid=conn.getUserId())]
for proj in projs:
print proj.getName()
proj = projs[0]