当前位置: 首页>>代码示例>>Python>>正文


Python CSAPI.setOptionComment方法代码示例

本文整理汇总了Python中DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI.setOptionComment方法的典型用法代码示例。如果您正苦于以下问题:Python CSAPI.setOptionComment方法的具体用法?Python CSAPI.setOptionComment怎么用?Python CSAPI.setOptionComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI的用法示例。


在下文中一共展示了CSAPI.setOptionComment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: toString

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOptionComment [as 别名]
for i in resultList:
    if not cfg.isSection("Resources/Sites/%s" % i):
        gLogger.error("Subsection /Resources/Sites/%s does not exists" % i)
        continue
    hasRun = True
    if SORTBYNAME:
        dirty = cfg["Resources"]["Sites"][i].sortAlphabetically(ascending=not REVERSE)
    else:
        dirty = cfg["Resources"]["Sites"][i].sortByKey(key=country, reverse=REVERSE)
    if dirty:
        isDirty = True

if not hasRun:
    gLogger.notice("Failed to find suitable subsections with site names to sort")
    DIRAC.exit(0)

if not isDirty:
    gLogger.notice("Nothing to do, site names are already sorted")
    DIRAC.exit(0)

timestamp = toString(dateTime())
stamp = "Site names are sorted by %s script at %s" % (Script.scriptName, timestamp)
cs.setOptionComment("/Resources/Sites", stamp)

result = cs.commit()
if not result["OK"]:
    gLogger.error("Failed to commit changes to CS", result["Message"])
    DIRAC.exit(2)
gLogger.notice("Site names are sorted and committed to CS")
DIRAC.exit(0)
开发者ID:sposs,项目名称:DIRAC,代码行数:32,代码来源:dirac-admin-sort-cs-sites.py

示例2: DiracAdmin

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOptionComment [as 别名]

#.........这里部分代码省略.........
        if gConfig.getValue( '/Resources/StorageElements/%s/%s/ProtocolName' % ( se, section ), '' ) == 'SRM2':
          path = '/Resources/StorageElements/%s/%s/ProtocolsList' % ( se, section )
          self.log.verbose( 'Setting %s to %s' % ( path, ', '.join( protocolsList ) ) )
          result = self.csSetOption( path, ', '.join( protocolsList ) )
          if not result['OK']:
            return result
          modifiedCS = True

    if modifiedCS:
      result = self.csCommitChanges( False )
      if not result[ 'OK' ]:
        return S_ERROR( 'CS Commit failed with message = %s' % ( result[ 'Message' ] ) )
      else:
        if printOutput:
          print 'Successfully committed changes to CS'
    else:
      if printOutput:
        print 'No modifications to CS required'

    return S_OK()

  #############################################################################
  def csSetOption( self, optionPath, optionValue ):
    """
    Function to modify an existing value in the CS.
    """
    return self.csAPI.setOption( optionPath, optionValue )

  #############################################################################
  def csSetOptionComment( self, optionPath, comment ):
    """
    Function to modify an existing value in the CS.
    """
    return self.csAPI.setOptionComment( optionPath, comment )

  #############################################################################
  def csModifyValue( self, optionPath, newValue ):
    """
    Function to modify an existing value in the CS.
    """
    return self.csAPI.modifyValue( optionPath, newValue )

  #############################################################################
  def csRegisterUser( self, username, properties ):
    """
    Registers a user in the CS.

        - username: Username of the user (easy;)
        - properties: Dict containing:
            - DN
            - groups : list/tuple of groups the user belongs to
            - <others> : More properties of the user, like mail

    """
    return self.csAPI.addUser( username, properties )

  #############################################################################
  def csDeleteUser( self, user ):
    """
    Deletes a user from the CS. Can take a list of users
    """
    return self.csAPI.deleteUsers( user )

  #############################################################################
  def csModifyUser( self, username, properties, createIfNonExistant = False ):
    """
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:70,代码来源:DiracAdmin.py


注:本文中的DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI.setOptionComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。