本文整理汇总了Python中WMCore.Cache.WMConfigCache.ConfigCache.getConfig方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigCache.getConfig方法的具体用法?Python ConfigCache.getConfig怎么用?Python ConfigCache.getConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Cache.WMConfigCache.ConfigCache
的用法示例。
在下文中一共展示了ConfigCache.getConfig方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testB_addingConfigsAndTweaks
# 需要导入模块: from WMCore.Cache.WMConfigCache import ConfigCache [as 别名]
# 或者: from WMCore.Cache.WMConfigCache.ConfigCache import getConfig [as 别名]
def testB_addingConfigsAndTweaks(self):
"""
_addingConfigsAndTweaks_
Test adding config files and tweak files
"""
PSetTweak = "Hello, I am a PSetTweak. It's nice to meet you."
attach = "Hello, I am an attachment"
configCache = ConfigCache(os.environ["COUCHURL"], couchDBName = 'config_test')
configCache.createUserGroup(groupname = "testGroup", username = 'testOps')
configCache.setPSetTweaks(PSetTweak = PSetTweak)
configCache.attachments['attach1'] = attach
psetPath = os.path.join(getTestBase(), "WMCore_t/Cache_t/PSet.txt")
configCache.addConfig(newConfig = psetPath, psetHash = None)
configCache.setLabel("sample-label")
configCache.setDescription("describe this config here")
configCache.save()
configString1 = configCache.getConfig()
configCache2 = ConfigCache(os.environ["COUCHURL"], couchDBName = 'config_test',
id = configCache.getCouchID(),
rev = configCache.getCouchRev())
configCache2.loadByID(configCache.getCouchID())
configString2 = configCache2.getConfig()
self.assertEqual(configString1, configString2)
self.assertEqual(configCache2.attachments.get('attach1', None), attach)
configCache.delete()
return
示例2: createAlgoFromInfo
# 需要导入模块: from WMCore.Cache.WMConfigCache import ConfigCache [as 别名]
# 或者: from WMCore.Cache.WMConfigCache.ConfigCache import getConfig [as 别名]
def createAlgoFromInfo(info):
"""
Create an Algo object from basic information
"""
algo = {'ApplicationName': info.get('ApplicationName'),
'ApplicationFamily': info.get('ApplicationFamily'),
'ApplicationVersion': info.get('ApplicationVersion'),
'PSetHash': info.get('PSetHash'),
'PSetContent': None,
'InDBS': info.get('AlgoInDBS', None)
}
configString = info.get('PSetContent')
if configString:
split = configString.split(';;')
cacheURL = split[0]
cacheDB = split[1]
configID = split[2]
try:
configCache = ConfigCache(cacheURL, cacheDB)
configCache.loadByID(configID)
algo['PSetContent'] = configCache.getConfig()
except Exception, ex:
msg = "Exception in getting configCache from DB\n"
msg += "Ignoring this exception and continuing without config.\n"
msg += str(ex)
msg += str(traceback.format_exc())
logging.error(msg)
logging.debug("URL: %s, DB: %s, ID: %s" % (cacheURL, cacheDB, configID))
示例3: showOriginalConfig
# 需要导入模块: from WMCore.Cache.WMConfigCache import ConfigCache [as 别名]
# 或者: from WMCore.Cache.WMConfigCache.ConfigCache import getConfig [as 别名]
def showOriginalConfig(self, docId):
""" Makes a link to the original text of the config """
configCache = ConfigCache(self.couchUrl, self.configDBName)
configCache.loadByID(docId)
configString = configCache.getConfig()
if configString == None:
return "Cannot find document " + str(docId) + " in Couch DB"
return '<pre>' + configString + '</pre>'
示例4: createAlgoFromInfo
# 需要导入模块: from WMCore.Cache.WMConfigCache import ConfigCache [as 别名]
# 或者: from WMCore.Cache.WMConfigCache.ConfigCache import getConfig [as 别名]
def createAlgoFromInfo(info):
"""
Create an Algo object from basic information
"""
algo = {
"ApplicationName": info["ApplicationName"],
"ApplicationFamily": info["ApplicationFamily"],
"ApplicationVersion": info["ApplicationVersion"],
"PSetHash": info["PSetHash"],
"PSetContent": None,
"InDBS": info["AlgoInDBS"],
}
configString = info.get("PSetContent")
if configString:
try:
split = configString.split(";;")
cacheURL = split[0]
cacheDB = split[1]
configID = split[2]
except IndexError:
msg = "configCache not properly formatted\n"
msg += "configString\n: %s" % configString
msg += "Not attempting to put configCache content in DBS for this algo"
msg += "AlgoInfo: %s" % algo
logging.error(msg)
return algo
if cacheURL == "None" or cacheDB == "None" or configID == "None":
# No Config for this DB
logging.debug("No configCache for this algo")
return algo
try:
configCache = ConfigCache(cacheURL, cacheDB)
configCache.loadByID(configID)
algo["PSetContent"] = configCache.getConfig()
except Exception as ex:
msg = "Exception in getting configCache from DB\n"
msg += "Ignoring this exception and continuing without config.\n"
msg += str(ex)
msg += str(traceback.format_exc())
logging.error(msg)
logging.debug("URL: %s, DB: %s, ID: %s" % (cacheURL, cacheDB, configID))
return algo
示例5: testE_SaveConfigFileToDisk
# 需要导入模块: from WMCore.Cache.WMConfigCache import ConfigCache [as 别名]
# 或者: from WMCore.Cache.WMConfigCache.ConfigCache import getConfig [as 别名]
def testE_SaveConfigFileToDisk(self):
"""
_SaveConfigFileToDisk_
Check and see if we can save the config file attachment to disk
"""
targetFile = os.path.join(self.testDir, 'configCache.test')
configCache = ConfigCache(os.environ["COUCHURL"], couchDBName = 'config_test')
configCache.createUserGroup(groupname = "testGroup", username = 'testOps')
configCache.attachments['configFile'] = 'ThisIsAConfigFile'
configCache.saveConfigToDisk(targetFile = targetFile)
f = open(targetFile, 'r')
content = f.read()
f.close()
self.assertEqual(content, configCache.getConfig())
return