本文整理汇总了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()