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


Python ContentCatalog.get_expiration方法代码示例

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


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

示例1: purge_expired

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_expiration [as 别名]
 def purge_expired(self, grace_period=GRACE_PERIOD):
     """
     Purge (delete) expired entries from the content catalog belonging
     to the specified content source by ID.
     :param grace_period: The grace period in seconds.
         The grace_period defines how long an entry is permitted to remain
         in the catalog after it has expired.  The default is 1 hour.
     :type grace_period: int
     """
     collection = ContentCatalog.get_collection()
     now = ContentCatalog.get_expiration(0)
     timestamp = now - grace_period
     query = {'expiration': {'$lt': timestamp}}
     collection.remove(query, safe=True)
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:16,代码来源:catalog.py

示例2: has_entries

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_expiration [as 别名]
 def has_entries(self, source_id):
     """
     Get whether the specified content source has entries in the catalog.
     :param source_id: A content source ID.
     :type source_id: str
     :return: True if has entries.
     :rtype: bool
     """
     collection = ContentCatalog.get_collection()
     query = {
         'source_id': source_id,
         'expiration': {'$gte': ContentCatalog.get_expiration(0)}
     }
     cursor = collection.find(query)
     return cursor.count() > 0
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:17,代码来源:catalog.py

示例3: find

# 需要导入模块: from pulp.server.db.model.content import ContentCatalog [as 别名]
# 或者: from pulp.server.db.model.content.ContentCatalog import get_expiration [as 别名]
 def find(self, type_id, unit_key):
     """
     Find entries in the content catalog using the specified unit type_id
     and unit_key.  The catalog may contain more than one entry matching the
     locator for a given content source.  In this case, only the newest entry
     for each source is included in the result set.
     :param type_id: The unit type ID.
     :type type_id: str
     :param unit_key: The unit key.
     :type unit_key: dict
     :return: A list of matching entries.
     :rtype: list
     """
     collection = ContentCatalog.get_collection()
     locator = ContentCatalog.get_locator(type_id, unit_key)
     query = {
         'locator': locator,
         'expiration': {'$gte': ContentCatalog.get_expiration(0)}
     }
     newest_by_source = {}
     for entry in collection.find(query, sort=[('_id', ASCENDING)]):
         newest_by_source[entry['source_id']] = entry
     return newest_by_source.values()
开发者ID:CUXIDUMDUM,项目名称:pulp,代码行数:25,代码来源:catalog.py


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