本文整理汇总了Python中WMCore.Database.CMSCouch.Document.__str__方法的典型用法代码示例。如果您正苦于以下问题:Python Document.__str__方法的具体用法?Python Document.__str__怎么用?Python Document.__str__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Database.CMSCouch.Document
的用法示例。
在下文中一共展示了Document.__str__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConfigCache
# 需要导入模块: from WMCore.Database.CMSCouch import Document [as 别名]
# 或者: from WMCore.Database.CMSCouch.Document import __str__ [as 别名]
#.........这里部分代码省略.........
@Decorators.requireGroup
@Decorators.requireUser
def delete(self):
"""
_delete_
Deletes the document with the current docid
"""
if not self.document["_id"]:
logging.error("Attempted to delete with no couch ID")
# TODO: Delete without loading first
try:
self.database.queueDelete(self.document)
self.database.commit()
except Exception as ex:
msg = "Error in deleting document from couch"
msg += str(ex)
msg += str(traceback.format_exc())
logging.error(msg)
raise ConfigCacheException(message = msg)
return
def getIDFromLabel(self, label):
"""
_getIDFromLabel_
Retrieve the ID of a config given it's label.
"""
results = self.database.loadView("ConfigCache", "config_by_label",
{"startkey": label,
"limit": 1})
if results["rows"][0]["key"] == label:
return results["rows"][0]["value"]
return None
def listAllConfigsByLabel(self):
"""
_listAllConfigsByLabel_
Retrieve a list of all the configs in the config cache. This is
returned in the form of a dictionary that is keyed by label.
"""
configs = {}
results = self.database.loadView("ConfigCache", "config_by_label")
for result in results["rows"]:
configs[result["key"]] = result["value"]
return configs
def __str__(self):
"""
Make something printable
"""
return self.document.__str__()
def validate(self, configID):
try:
#TODO: need to change to DataCache
#self.loadDocument(configID = configID)
self.loadByID(configID = configID)
except Exception as ex:
raise ConfigCacheException("Failure to load ConfigCache while validating workload: %s" % str(ex))
if self.detail:
duplicateCheck = {}
try:
outputModuleInfo = self.getOutputModuleInfo()
except Exception as ex:
# Something's gone wrong with trying to open the configCache
msg = "Error in getting output modules from ConfigCache during workload validation. Check ConfigCache formatting!"
raise ConfigCacheException("%s: %s" % (msg, str(ex)))
for outputModule in outputModuleInfo.values():
dataTier = outputModule.get('dataTier', None)
filterName = outputModule.get('filterName', None)
if not dataTier:
raise ConfigCacheException("No DataTier in output module.")
# Add dataTier to duplicate dictionary
if not dataTier in duplicateCheck.keys():
duplicateCheck[dataTier] = []
if filterName in duplicateCheck[dataTier]:
# Then we've seen this combination before
raise ConfigCacheException("Duplicate dataTier/filterName combination.")
else:
duplicateCheck[dataTier].append(filterName)
return outputModuleInfo
else:
return True