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


Python RequestContainer.setAttribute方法代码示例

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


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

示例1: sweeper

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import setAttribute [as 别名]
 def sweeper( cls ):
   """ move cached request to the central request manager
   
   :param cls: class reference
   """
   cacheDir = cls.cacheDir()    
   ## cache dir empty? 
   if not os.listdir( cacheDir ):
     gLogger.always("sweeper: CacheDir %s is empty, nothing to do" % cacheDir )
     return S_OK()
   else:  
     ## read 10 cache dir files, the oldest first 
     cachedRequests = [ os.path.abspath( requestFile ) for requestFile in
                        sorted( filter( os.path.isfile,
                                        [ os.path.join( cacheDir, requestName ) 
                                          for requestName in os.listdir( cacheDir ) ] ),
                                key = os.path.getctime ) ][:30]
     ## set cached requests to the central RequestManager
     for cachedFile in cachedRequests:
       try:
         requestString = "".join( open( cachedFile, "r" ).readlines() )
         cachedRequest = RequestContainer( requestString )
         requestName = cachedRequest.getAttribute("RequestName")["Value"]
         ## cibak: hack for DISET requests
         if requestName == "Unknown":
           cachedRequest.setAttribute( "RequestName", makeGuid() )
           requestName = cachedRequest.getAttribute("RequestName")["Value"]
         setRequest = cls.requestManager().setRequest( requestName, requestString )
         if not setRequest["OK"]:
           gLogger.error("sweeper: unable to set request '%s' @ RequestManager: %s" % ( requestName, 
                                                                                        setRequest["Message"] ) )
           continue
         gLogger.info("sweeper: successfully set request '%s' @ RequestManager" % requestName  )
         os.unlink( cachedFile )
       except Exception, error:
         gLogger.exception( "sweeper: hit by exception %s" % str(error) )
         return S_ERROR( "sweeper: hit by exception: %s" % str(error) )
     return S_OK()
开发者ID:IgorPelevanyuk,项目名称:DIRAC,代码行数:40,代码来源:RequestProxyHandler.py


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