本文整理匯總了Python中DIRAC.ConfigurationSystem.private.Modificator.Modificator.getCFG方法的典型用法代碼示例。如果您正苦於以下問題:Python Modificator.getCFG方法的具體用法?Python Modificator.getCFG怎麽用?Python Modificator.getCFG使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DIRAC.ConfigurationSystem.private.Modificator.Modificator
的用法示例。
在下文中一共展示了Modificator.getCFG方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __getRemoteConfiguration
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import getCFG [as 別名]
def __getRemoteConfiguration(self, funcName):
rpcClient = RPCClient(gConfig.getValue("/DIRAC/Configuration/MasterServer", "Configuration/Server"))
modCfg = Modificator(rpcClient)
retVal = modCfg.loadFromRemote()
if not retVal[ 'OK' ]:
return {"success":0, "op":"getSubnodes", "message":"The configuration cannot be read from the remote !"}
self.__configData[ 'cfgData' ] = modCfg
self.__configData[ 'strCfgData' ] = str(modCfg)
version = str(modCfg.getCFG()["DIRAC"]["Configuration"]["Version"])
configName = str(modCfg.getCFG()["DIRAC"]["Configuration"]["Name"])
return {"success":1, "op":funcName, "version":version, "name":configName}
示例2: __init__
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import getCFG [as 別名]
#.........這裏部分代碼省略.........
def mergeFromCFG( self, cfg ):
""" Merge the internal CFG data with the input
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.mergeFromCFG( cfg )
self.__csModified = True
return S_OK()
def modifyValue( self, optionPath, newValue ):
"""Modify an existing value at the specified options path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
prevVal = self.__csMod.getValue( optionPath )
if not prevVal:
return S_ERROR( 'Trying to set %s to %s but option does not exist' % ( optionPath, newValue ) )
gLogger.verbose( "Changing %s from \n%s \nto \n%s" % ( optionPath, prevVal, newValue ) )
self.__csMod.setOptionValue( optionPath, newValue )
self.__csModified = True
return S_OK( 'Modified %s' % optionPath )
def setOption( self, optionPath, optionValue ):
"""Create an option at the specified path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.setOptionValue( optionPath, optionValue )
self.__csModified = True
return S_OK( 'Created new option %s = %s' % ( optionPath, optionValue ) )
def setOptionComment( self, optionPath, comment ):
"""Create an option at the specified path.
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.setComment( optionPath, comment )
self.__csModified = True
return S_OK( 'Set option comment %s : %s' % ( optionPath, comment ) )
def delOption( self, optionPath ):
""" Delete an option
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeOption( optionPath ):
return S_ERROR( "Couldn't delete option %s" % optionPath )
self.__csModified = True
return S_OK( 'Deleted option %s' % ( optionPath ) )
def createSection( self, sectionPath, comment = "" ):
""" Create a new section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.createSection( sectionPath )
self.__csModified = True
if comment:
self.__csMod.setComment( sectionPath, comment )
return S_OK()
def delSection( self, sectionPath ):
""" Delete a section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeSection( sectionPath ):
return S_ERROR( "Could not delete section %s " % sectionPath )
self.__csModified = True
return S_OK()
def mergeCFGUnderSection( self, sectionPath, cfg ):
""" Merge the given cfg under a certain section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
result = self.createSection( sectionPath )
if not result[ 'OK' ]:
return result
if not self.__csMod.mergeSectionFromCFG( sectionPath, cfg ):
return S_ERROR( "Could not merge cfg into section %s" % sectionPath )
self.__csModified = True
return S_OK()
def mergeWithCFG( self, cfg ):
""" Merge the given cfg with the current config
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.mergeFromCFG( cfg )
self.__csModified = True
return S_OK()
def getCurrentCFG( self ):
""" Get the current CFG as it is
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
return S_OK( self.__csMod.getCFG() )
示例3: CSAPI
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import getCFG [as 別名]
#.........這裏部分代碼省略.........
return self.__initialized
self.__csMod.setComment( optionPath, comment )
self.csModified = True
return S_OK( 'Set option comment %s : %s' % ( optionPath, comment ) )
def delOption( self, optionPath ):
""" Delete an option
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeOption( optionPath ):
return S_ERROR( "Couldn't delete option %s" % optionPath )
self.csModified = True
return S_OK( 'Deleted option %s' % optionPath )
def createSection( self, sectionPath, comment = "" ):
""" Create a new section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.createSection( sectionPath )
self.csModified = True
if comment:
self.__csMod.setComment( sectionPath, comment )
return S_OK()
def delSection( self, sectionPath ):
""" Delete a section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
if not self.__csMod.removeSection( sectionPath ):
return S_ERROR( "Could not delete section %s " % sectionPath )
self.csModified = True
return S_OK( )
def copySection( self, originalPath, targetPath ):
""" Copy a whole section to a new location
"""
if not self.__initialized['OK']:
return self.__initialized
cfg = self.__csMod.getCFG( )
sectionCfg = cfg[originalPath]
result = self.createSection( targetPath )
if not result['OK']:
return result
if not self.__csMod.mergeSectionFromCFG( targetPath, sectionCfg ):
return S_ERROR( "Could not merge cfg into section %s" % targetPath )
self.csModified = True
return S_OK( )
def moveSection( self, originalPath, targetPath ):
""" Move a whole section to a new location
"""
result = self.copySection( originalPath, targetPath )
if not result['OK']:
return result
result = self.delSection( originalPath )
if not result['OK']:
return result
self.csModified = True
return S_OK()
def mergeCFGUnderSection( self, sectionPath, cfg ):
""" Merge the given cfg under a certain section
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
result = self.createSection( sectionPath )
if not result[ 'OK' ]:
return result
if not self.__csMod.mergeSectionFromCFG( sectionPath, cfg ):
return S_ERROR( "Could not merge cfg into section %s" % sectionPath )
self.csModified = True
return S_OK()
def mergeWithCFG( self, cfg ):
""" Merge the given cfg with the current config
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
self.__csMod.mergeFromCFG( cfg )
self.csModified = True
return S_OK()
def getCurrentCFG( self ):
""" Get the current CFG as it is
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
return S_OK( self.__csMod.getCFG() )
def showDiff( self ):
""" Just shows the differences accumulated within the Modificator object
"""
diffData = self.__csMod.showCurrentDiff()
gLogger.notice( "Accumulated diff with master CS" )
for line in diffData:
if line[0] in ( '+', '-' ):
gLogger.notice( line )