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


Python DiracAdmin.csModifyUser方法代码示例

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


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

示例1: addUserToCS

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csModifyUser [as 别名]
def addUserToCS(clip, userProps):
  """Add the user to the CS, return list of errors"""
  from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
  diracAdmin = DiracAdmin()
  exitCode = 0
  errorList = []

  if not diracAdmin.csModifyUser( clip.uname, userProps, createIfNonExistant = True )['OK']:
    errorList.append( ( "add user", "Cannot register user: '%s'" % clip.uname ) )
    exitCode = 255
  else:
    result = diracAdmin.csCommitChanges()
    if not result[ 'OK' ]:
      errorList.append( ( "commit", result[ 'Message' ] ) )
      exitCode = 255
  for error in errorList:
    gLogger.error( "%s: %s" % error )
  if exitCode:
    dexit(exitCode)
开发者ID:LCDsoft,项目名称:ILCDIRAC,代码行数:21,代码来源:dirac-ilc-add-user.py

示例2: in

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csModifyUser [as 别名]
    forceCreation = True
  elif unprocSw[0] in ( "p", "property" ):
    prop = unprocSw[1]
    pl = prop.split( "=" )
    if len( pl ) < 2:
      errorList.append( ( "in arguments", "Property %s has to include a '=' to separate name from value" % prop ) )
      exitCode = 255
    else:
      pName = pl[0]
      pValue = "=".join( pl[1:] )
      print "Setting property %s to %s" % ( pName, pValue )
      userProps[ pName ] = pValue

userName = args[0]
userProps[ 'DN' ] = args[1]
userProps[ 'Groups' ] = args[2:]

if not diracAdmin.csModifyUser( userName, userProps, createIfNonExistant = forceCreation ):
  errorList.append( ( "modify user", "Cannot modify user %s" % userName ) )
  exitCode = 255
else:
  result = diracAdmin.csCommitChanges()
  if not result[ 'OK' ]:
    errorList.append( ( "commit", result[ 'Message' ] ) )
    exitCode = 255

for error in errorList:
  print "ERROR %s: %s" % error

DIRAC.exit( exitCode )
开发者ID:sbel,项目名称:bes3-jinr,代码行数:32,代码来源:dirac-admin-modify-user.py

示例3: len

# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csModifyUser [as 别名]
exitCode = 0
errorList = []

userProps = {"DN": userDN, "Email": userMail}
if userGroups:
    userProps["Groups"] = userGroups
for prop in args:
    pl = prop.split("=")
    if len(pl) < 2:
        errorList.append(("in arguments", "Property %s has to include a '=' to separate name from value" % prop))
        exitCode = 255
    else:
        pName = pl[0]
        pValue = "=".join(pl[1:])
        Script.gLogger.info("Setting property %s to %s" % (pName, pValue))
        userProps[pName] = pValue

if not diracAdmin.csModifyUser(userName, userProps, createIfNonExistant=True)["Value"]:
    errorList.append(("add user", "Cannot register user %s" % userName))
    exitCode = 255
else:
    result = diracAdmin.csCommitChanges()
    if not result["OK"]:
        errorList.append(("commit", result["Message"]))
        exitCode = 255

for error in errorList:
    Script.gLogger.error("%s: %s" % error)

DIRAC.exit(exitCode)
开发者ID:roiser,项目名称:DIRAC,代码行数:32,代码来源:dirac-admin-add-user.py


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