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


Python RequestClient.selectRequests方法代码示例

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


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

示例1: RequestCleaningAgent

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestClient import RequestClient [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestClient.RequestClient import selectRequests [as 别名]
class RequestCleaningAgent(AgentModule):

  def initialize(self):

    self.graceRemovalPeriod = self.am_getOption('GraceRemovalPeriod',7)
    self.checkAssigned = self.am_getOption('CheckAssigned',True)
    self.assignedResetDelay = self.am_getOption('AssignedResetDelay',7200)
    self.ftsCleaning = self.am_getOption('FTSCleaning',True)
    self.requestClient = RequestClient()
    
    return S_OK()

  def execute(self):
    """ Main execution method
    """
    
    toDate = dateTime() - day*self.graceRemovalPeriod
    result = self.requestClient.selectRequests({'Status':'Done','ToDate':str(toDate)})
    if not result['OK']:
      return result
    requestDict = result['Value']
    for rID,rName in requestDict.items():

      gLogger.verbose("Removing request %s" % rName)
      result = self.requestClient.deleteRequest(rName)
      if not result['OK']:
        gLogger.error('Failed to delete request %s' % rName, result['Message'])
      else:
        gLogger.info('Successfully removed request %d/%s' % (rID,rName) )
      
    if self.checkAssigned:
      toDate = dateTime() - second*self.assignedResetDelay
      result = self.requestClient.selectRequests({'Status':'Assigned','ToDate':str(toDate)})
      if not result['OK']:
        return result
      requestDict = result['Value']
      for rID,rName in requestDict.items():
        gLogger.verbose("Resetting request %s to Waiting" % rName)
        result = self.requestClient.setRequestStatus(rName,'Waiting')
        if not result['OK']:
          gLogger.error('Failed to reset request %s to Waiting' % rName, result['Message'])
        else:
          gLogger.info('Successfully reset request %d/%s to Waiting' % (rID,rName) )

    if self.ftsCleaning:
      pass
    
    return S_OK()  
开发者ID:bmb,项目名称:DIRAC,代码行数:50,代码来源:RequestCleaningAgent.py


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