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


Python WMStatsWriter.getArchivedRequests方法代码示例

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


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

示例1: CleanUpTask

# 需要导入模块: from WMCore.Services.WMStats.WMStatsWriter import WMStatsWriter [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsWriter.WMStatsWriter import getArchivedRequests [as 别名]
class CleanUpTask(CherryPyPeriodicTask):
    """
    This class is used for both T0WMStats and WMStats
    controlled by config.reqdb_couch_app value
    """

    def __init__(self, rest, config):

        super(CleanUpTask, self).__init__(config)
        self.wmstatsDB = WMStatsWriter(config.wmstats_url, reqdbURL=config.reqmgrdb_url,
                              reqdbCouchApp=config.reqdb_couch_app)

    def setConcurrentTasks(self, config):
        """
        sets the list of functions which runs concurrently
        """
        self.concurrentTasks = [{'func': self.cleanUpOldRequests, 'duration': (config.DataKeepDays * 24 * 60 * 60)},
                                {'func': self.cleanUpArchivedRequests, 'duration': config.archivedCleanUpDuration}]

    def cleanUpOldRequests(self, config):
        """
        clean up wmstats data older then given days
        """
        self.logger.info("deleting %s hours old docs", (config.DataKeepDays * 24))
        result = self.wmstatsDB.deleteOldDocs(config.DataKeepDays)
        self.logger.info("%s old doc deleted", result)
        return

    def cleanUpArchivedRequests(self, config):
        """
        loop through the workflows in couchdb, if archived delete all the data in couchdb
        """
        self.logger.info("getting archived data")
        requestNames = self.wmstatsDB.getArchivedRequests()
        self.logger.info("archived list %s", requestNames)

        for req in requestNames:
            self.logger.info("Deleting data for: %s", req)
            try:
                result = self.wmstatsDB.deleteDocsByWorkflow(req)
            except Exception as ex:
                self.logger.error("deleting %s failed: %s", req, str(ex))
                for line in traceback.format_exc().rstrip().split("\n"):
                    self.logger.error(" " + line)
            else:
                if result is None:
                    self.logger.info("there were no documents to delete.")
                else:
                    self.logger.info("%s docs deleted", len(result))
        return
开发者ID:amaltaro,项目名称:WMCore,代码行数:52,代码来源:CleanUpTask.py

示例2: CleanUpTask

# 需要导入模块: from WMCore.Services.WMStats.WMStatsWriter import WMStatsWriter [as 别名]
# 或者: from WMCore.Services.WMStats.WMStatsWriter.WMStatsWriter import getArchivedRequests [as 别名]
class CleanUpTask(CherryPyPeriodicTask):
    """
    This class is used for both T0WMStats and WMStats
    controlled by config.reqdb_couch_app value
    """

    def __init__(self, rest, config):

        CherryPyPeriodicTask.__init__(self, config)
        self.wmstatsDB = WMStatsWriter(
            config.wmstats_url, reqdbURL=config.reqmgrdb_url, reqdbCouchApp=config.reqdb_couch_app
        )

    def setConcurrentTasks(self, config):
        """
        sets the list of functions which
        """
        self.concurrentTasks = [
            {"func": self.cleanUpOldRequests, "duration": (config.DataKeepDays * 24 * 60 * 60)},
            {"func": self.cleanUpArchivedRequests, "duration": config.archivedCleanUpDuration},
        ]

    def cleanUpOldRequests(self, config):
        """
        clean up wmstats data older then given days
        """
        self.logger.info("deleting %s hours old docs" % (config.DataKeepDays * 24))
        result = self.wmstatsDB.deleteOldDocs(config.DataKeepDays)
        self.logger.info("%s old doc deleted" % result)
        return

    def cleanUpArchivedRequests(self, config):
        """
        loop through the workflows in couchdb, if archived delete all the data in couchdb
        """

        requestNames = self.wmstatsDB.getArchivedRequests()
        for req in requestNames:
            self.logger.info("deleting %s data" % req)
            result = self.wmstatsDB.deleteDocsByWorkflow(req)
            self.logger.info("%s deleted" % result)
        return
开发者ID:prozober,项目名称:WMCore,代码行数:44,代码来源:CleanUpTask.py


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