本文整理匯總了Python中DIRAC.ConfigurationSystem.private.Modificator.Modificator.existsSection方法的典型用法代碼示例。如果您正苦於以下問題:Python Modificator.existsSection方法的具體用法?Python Modificator.existsSection怎麽用?Python Modificator.existsSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DIRAC.ConfigurationSystem.private.Modificator.Modificator
的用法示例。
在下文中一共展示了Modificator.existsSection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CSCLI
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import existsSection [as 別名]
#.........這裏部分代碼省略.........
"""
Connects to configuration master server (in specified url if provided).
Usage: connect <url>
"""
if not args or type( args ) not in types.StringTypes:
self.masterURL = gConfigurationData.getMasterServer()
if self.masterURL != "unknown" and self.masterURL:
self._tryConnection()
else:
self._setStatus( False )
else:
splitted = args.split()
if len( splitted ) == 0:
print "Must specify witch url to connect"
self._setStatus( False )
else:
self.masterURL = splitted[0].strip()
self._tryConnection()
def do_sections( self, args ):
"""
Shows all sections with their comments.
If no section is specified, root is taken.
Usage: sections <section>
"""
try:
argList = args.split()
if argList:
baseSection = argList[0].strip()
else:
baseSection = "/"
if not self.modificator.existsSection( baseSection ):
print "Section %s does not exist" % baseSection
return
sectionList = self.modificator.getSections( baseSection )
if not sectionList:
print "Section %s is empty" % baseSection
return
for section in sectionList:
section = "%s/%s" % ( baseSection, section )
self.printPair( section, self.modificator.getComment( section ) , " #" )
except:
_showTraceback()
def do_options( self, args ):
"""
Shows all options and values of a specified section
Usage: options <section>
"""
try:
argList = args.split()
if argList:
section = argList[0].strip()
else:
print "Which section?"
return
if not self.modificator.existsSection( section ):
print "Section %s does not exist" % section
return
optionsList = self.modificator.getOptions( section )
if not optionsList:
print "Section %s has no options" % section
return
示例2: __init__
# 需要導入模塊: from DIRAC.ConfigurationSystem.private.Modificator import Modificator [as 別名]
# 或者: from DIRAC.ConfigurationSystem.private.Modificator.Modificator import existsSection [as 別名]
#.........這裏部分代碼省略.........
self.__csMod.setOptionValue( "%s/Groups/%s/Users" % ( self.__baseSecurity, group ),
",".join( filteredUsers ) )
def __addResourceLikeSection( self, resourcePath, resourceDict ):
""" Add one of Resource level entries ( site, resource, access point )
"""
self.__csMod.createSection( resourcePath )
for property in resourceDict:
value = resourceDict[property]
if type( value ) in types.StringTypes:
self.__csMod.setOptionValue( "%s/%s" % ( resourcePath, property ), value )
elif type( value ) == types.ListType:
optValue = ','.join(value)
self.__csMod.setOptionValue( "%s/%s" % ( resourcePath, property ), optValue )
elif type( value ) == types.DictType:
self.__csMod.createSection( "%s/%s" % ( resourcePath, property ) )
for option in value:
newValue = value[option]
if type( newValue ) in types.StringTypes:
self.__csMod.setOptionValue( "%s/%s/%s" % ( resourcePath, property, option ), newValue )
elif type( value ) == types.ListType:
optValue = ','.join( newValue)
self.__csMod.setOptionValue( "%s/%s/%s" % ( resourcePath, property, option ), optValue )
self.__csModified = True
return S_OK( True )
def addSite( self, siteName, siteDict ):
""" Add a new Site to the CS
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
sitePath = "%s/Sites/%s" % ( self.__baseResources, siteName )
if self.__csMod.existsSection( sitePath ):
return S_ERROR( 'Site %s already exists ' % siteName )
return self.__addResourceLikeSection( sitePath, siteDict )
def addResource( self, siteName, resourceType, resourceName, resourceDict ):
""" Add a new Resource to the CS
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
sitePath = "%s/Sites/%s" % ( self.__baseResources, siteName )
if not self.__csMod.existsSection( sitePath ):
return S_ERROR( 'Site %s does not exist' % siteName )
resourcePath = "%s/Sites/%s/%s/%s" % ( self.__baseResources, siteName, resourceType, resourceName )
if self.__csMod.existsSection( resourcePath ):
return S_ERROR( '%s resource %s at site %s already exists' % ( resourceType, resourceName, siteName ) )
return self.__addResourceLikeSection( resourcePath, resourceDict )
def addNode( self, siteName, resourceType, resourceName, apType, apName, apDict ):
""" Add a new site to the CS
"""
if not self.__initialized[ 'OK' ]:
return self.__initialized
sitePath = "%s/Sites/%s" % ( self.__baseResources, siteName )
if not self.__csMod.existsSection( sitePath ):
return S_ERROR( 'Site %s does not exist' % siteName )
resourcePath = "%s/Sites/%s/%s/%s" % ( self.__baseResources, siteName, resourceType, resourceName )
if not self.__csMod.existsSection( resourcePath ):
return S_ERROR( '%s resource %s at site %s does not exist' % ( resourceType, resourceName, siteName ) )
apPath = "%s/Sites/%s/%s/%s/%s/%s" % ( self.__baseResources, siteName, resourceType, resourceName, apType, apName )
if self.__csMod.existsSection( apPath ):
return S_ERROR( '%s access point %s at %s resource %s at site %s already exists ' % \
( apType, apName, resourceType, resourceName, siteName ) )
return self.__addResourceLikeSection( apPath, apDict )