当前位置: 首页>>代码示例>>Python>>正文


Python BlitzGateway.suConn方法代码示例

本文整理汇总了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
开发者ID:imcf,项目名称:omero-user-scripts,代码行数:22,代码来源:export_treestructure.py

示例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]
开发者ID:imcf,项目名称:imcf-toolbox,代码行数:33,代码来源:sandbox.py


注:本文中的omero.gateway.BlitzGateway.suConn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。