How to use the dirac.lib.credentials.getProperties function in DIRAC

To help you get started, we’ve selected a few DIRAC examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
req["JobID"] = testString
          else:
            req["JobID"] = testString
        else:
          req["JobID"] = testString
      else:
        req["JobID"] = testString
      for i in req["JobID"]:
        testI = i.split('-')
        if len(testI) == 2:
          testI[0] = testI[0].strip(' ')
          testI[1] = testI[1].strip(' ')
          rangeID = range(testI[0],testI[1])
          gLogger.info("RANGE:",rangeID)
    else:
      groupProperty = credentials.getProperties(group)
      gLogger.always("### groupProperty: ",str(groupProperty))
      result = gConfig.getOption("/Website/ListSeparator")
      if result["OK"]:
        separator = result["Value"]
      else:
        separator = ":::"
      if request.params.has_key("prod") and len(request.params["prod"]) > 0:
        if str(request.params["prod"]) != "All":
          req["JobGroup"] = str(request.params["prod"]).split(separator)
      if request.params.has_key("site") and len(request.params["site"]) > 0:
        if str(request.params["site"]) != "All":
          req["Site"] = [x.strip() for x in str(request.params["site"]).split(separator)]
      if request.params.has_key("status") and len(request.params["status"]) > 0:
        if str(request.params["status"]) != "All":
          req["Status"] = str(request.params["status"]).split(separator)
      if request.params.has_key("minorstat") and len(request.params["minorstat"]) > 0:
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
def display(self):
    pagestart = time()
    group = credentials.getSelectedGroup()
    if group == "visitor" and credentials.getUserDN() == "":
      return render("/login.mako")
    c.select = self.__getSelectionData()
    if not c.select.has_key("extra"):
      groupProperty = credentials.getProperties(group)
      if "JobAdministrator" not in groupProperty and "JobSharing" not in groupProperty:
        c.select["extra"] = {"owner":credentials.getUsername()}
    return render("jobs/JobMonitor.mako")
################################################################################
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / webBase.py View on Github external
def checkPropertiesWithUser( properties ):
  if 'all' in properties:
    return True
  if credentials.getSelectedGroup() != 'visitor' and 'authenticated' in properties:
    return True
  for userProp in credentials.getProperties():
    if userProp in properties:
      return True
  return False
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / webBase.py View on Github external
def getUserData():
  userData = []
  username = credentials.getUsername()
  if not username or username == "anonymous":
    userData.append( "username : 'Anonymous'" )
  else:
    userData.append( "username : '%s'" % username )
    userData.append( "group : '%s'" % credentials.getSelectedGroup() )
    properties = credentials.getProperties( credentials.getSelectedGroup() )
    if len( properties ) > 0:
      userData.append( "groupProperties : %s" % properties )
    else:
      userData.append( "groupProperties : []" )
    availableGroups = list()
    for groupName in credentials.getAvailableGroups():
      properties = credentials.getProperties( groupName )
      if not len( properties ) > 0:
        continue
      if ( "Pilot" in properties ) or ( "GenericPilot" in properties ):
        continue
      url = diracURL( controller = 'web/userdata',
                      action = 'changeGroup',
                      id = groupName )
      availableGroups.append( "{ text : '%s', url : '%s' }" %
                                ( groupName , url ) )
github DIRACGrid / -obsolete-DIRACWeb / dirac / lib / webBase.py View on Github external
def getUserData():
  userData = []
  username = credentials.getUsername()
  if not username or username == "anonymous":
    userData.append( "username : 'Anonymous'" )
  else:
    userData.append( "username : '%s'" % username )
    userData.append( "group : '%s'" % credentials.getSelectedGroup() )
    properties = credentials.getProperties( credentials.getSelectedGroup() )
    if len( properties ) > 0:
      userData.append( "groupProperties : %s" % properties )
    else:
      userData.append( "groupProperties : []" )
    availableGroups = list()
    for groupName in credentials.getAvailableGroups():
      properties = credentials.getProperties( groupName )
      if not len( properties ) > 0:
        continue
      if ( "Pilot" in properties ) or ( "GenericPilot" in properties ):
        continue
      url = diracURL( controller = 'web/userdata',
                      action = 'changeGroup',
                      id = groupName )
      availableGroups.append( "{ text : '%s', url : '%s' }" %
                                ( groupName , url ) )
    userData.append( "groupMenu : [%s]" % ",".join( availableGroups ) )
  dn = credentials.getUserDN()
  if not dn:
    if 'REQUEST_URI' in request.environ:
      uri = str( request.environ[ 'REQUEST_URI' ] )
    else:
      uri = ""
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / info / general.py View on Github external
def getUserByProperty( self , prop = "NormalUser" ):

    """
    Get usernames based on group property
    Argument is a string. Return value is a list
    """

    groupList = list()
    result = gConfig.getSections( "/Registry/Groups" )
    gLogger.debug( "Group response: %s" % result )
    if not result[ "OK" ]:
      return groupList

    groups = result[ "Value" ]
    for j in groups:
      props = getProperties( j )
      gLogger.debug( "%s properties: %s" % ( j , props ) )
      if prop in props:
        groupList.append( j )

    if not len( groupList ) > 0:
      return groupList
    groupList = uniqueElements( groupList )
    gLogger.debug( "Chosen group(s): %s" % groupList )

    userList = list()
    for i in groupList:
      users = gConfig.getValue( "/Registry/Groups/%s/Users" % i , [] )
      gLogger.debug( "%s users: %s" % ( i , users ) )
      if len( users ) > 0:
        userList.extend( users )