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


Python BlitzGateway._closeSession方法代码示例

本文整理汇总了Python中omero.gateway.BlitzGateway._closeSession方法的典型用法代码示例。如果您正苦于以下问题:Python BlitzGateway._closeSession方法的具体用法?Python BlitzGateway._closeSession怎么用?Python BlitzGateway._closeSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在omero.gateway.BlitzGateway的用法示例。


在下文中一共展示了BlitzGateway._closeSession方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Connection

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import _closeSession [as 别名]
class Connection(object):
    """
    A wrapper for managing a client session context
    """

    def __init__(self, user = None, passwd = None, host = None, client = None):
        """
        Create a new client session, either by specifying user and passwd or by
        providing a client object (for scripts)
        @param user Username
        @param passwd Password
        @param host The server hostname
        @param client Client object with an active session
        """

        self.log = logging.getLogger(__name__)
        #self.log.setLevel(logging.DEBUG)

        if not client:
            client = omero.client(host)
            sess = client.createSession(user, passwd)
            client.enableKeepAlive(60)
        else:
            sess = client.getSession()

        self.conn = BlitzGateway(client_obj = client)

        self.res = sess.sharedResources()
        if (not self.res.areTablesEnabled()):
            raise TableConnectionError('OMERO.tables not enabled')

    def __enter__(self):
        self.log.debug('Entering Connection')
        return self

    def __exit__(self, type, value, traceback):
        self.log.debug('Exiting Connection')
        self.close()

    def close(self):
        """
        Child classes can override this method but must explcitly call this
        method to ensure the client session is cleaned
        """
        self.log.debug('Closing Connection')
        self.conn._closeSession()
开发者ID:colettace,项目名称:omero-pychrm,代码行数:48,代码来源:TableConnection.py

示例2: zip

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import _closeSession [as 别名]
halfRecovery = (recoveryValue + bleachValue)/2

# quick & dirty - pick the first timepoint where we exceed half recovery
recoveryValues = valueList[bleachTindex:]   # just the values & times after bleach time
recoveryTimes = timeList[bleachTindex:]
for t, v in zip(recoveryTimes, recoveryValues):
    if v >= halfRecovery:
        tHalf = t - bleachTime
        break

print "tHalf: %0.2f seconds" % tHalf


csvLines = [ 
    "Time (secs)," + ",".join([str(t) for t in timeList]),
    "\n",
    "Average pixel value," + ",".join([str(v) for v in valueList]),
    "\n",
    "tHalf (secs), %0.2f seconds" % tHalf,
    "mobileFraction, %0.2f" % mobileFraction
    ]

f = open("FRAP.csv", "w")
f.writelines(csvLines)
f.close()

# Close connection:
# =================================================================
# When you are done, close the session to free up server resources.
conn._closeSession()
开发者ID:bramalingam,项目名称:openmicroscopy,代码行数:32,代码来源:Simple_FRAP.py

示例3: TableConnection

# 需要导入模块: from omero.gateway import BlitzGateway [as 别名]
# 或者: from omero.gateway.BlitzGateway import _closeSession [as 别名]
class TableConnection(object):
    """
    A basic client-side wrapper for OMERO.tables which handles opening
    and closing tables.
    """

    def __init__(self, user = None, passwd = None, host = 'localhost',
                 client = None, tableName = None, tableId = None):
        """
        Create a new table handler, either by specifying user and passwd or by
        providing a client object (for scripts)
        @param user Username
        @param passwd Password
        @param host The server hostname
        @param client Client object with an active session
        @param tableName The name of the table file
        @param tableId The OriginalFile ID of the table file
        """
        if not client:
            client = omero.client(host)
            sess = client.createSession(user, passwd)
            client.enableKeepAlive(60)
        else:
             sess = client.getSession()

        self.conn = BlitzGateway(client_obj = client)

        self.res = sess.sharedResources()
        if (not self.res.areTablesEnabled()):
            raise TableConnectionError('OMERO.tables not enabled')

        repos = self.res.repositories()
        self.rid = repos.descriptions[0].id.val

        self.tableName = tableName
        self.tableId = tableId
        self.table = None

    def __enter__(self):
        print 'Entering Connection'
        return self

    def __exit__(self, type, value, traceback):
        print 'Exiting Connection'
        self.close()

    def close(self):
        print 'Closing Connection'
        try:
            self.closeTable()
        finally:
            self.conn._closeSession()


    def openTable(self, tableId = None, tableName = None):
        """
        Opens an existing table by ID or name.
        If there are multiple tables with the same name this throws an error
        (should really use an annotation to keep track of this).
        If tableId is supplied it will be used in preference to tableName
        @param tableName The name of the table file
        @param tableId The OriginalFile ID of the table file
        @return handle to the table
        """
        if not tableId and not tableName:
            tableId = self.tableId
            tableName = self.tableName

        if not tableId:
            if not tableName:
                tableName = self.tableName
            attrs = {'name': tableName}
            ofiles = list(
                self.conn.getObjects("OriginalFile", attributes = attrs))
            if len(ofiles) > 1:
                raise TableConnectionError(
                    'Multiple tables with name:%s found' % tableName)
            if not ofiles:
                raise TableConnectionError(
                    'No table found with name:%s' % tableName)
            ofile = ofiles[0]
        else:
            attrs = {'id': long(tableId)}
            if tableName:
                attrs['name'] = tableName
            ofile = self.conn.getObject("OriginalFile", attributes = attrs)

        if not ofile:
            raise TableConnectionError('No table found with name:%s id:%s' %
                                       (tableName, tableId))

        if self.tableId == ofile.getId():
            print 'Using existing connection to table name:%s id:%d' % \
                (tableName, tableId)
        else:
            self.closeTable()
            self.table = self.res.openTable(ofile._obj)
            self.tableId = ofile.getId()
            print 'Opened table name:%s id:%d' % (tableName, self.tableId)

#.........这里部分代码省略.........
开发者ID:manics,项目名称:alternative-storage,代码行数:103,代码来源:TableConnection.py


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