How to use the dirac.controllers.info.general.GeneralController 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 / SiteSummary.py View on Github external
elif request.params.has_key("expand") and len(request.params["expand"]) > 0:
      globalSort = [["GridSite","ASC"]]
      numberOfJobs = 500
      pageNumber = 0
      req["ExpandSite"] = str(request.params["expand"])
    else:
      result = gConfig.getOption("/Website/ListSeparator")
      if result["OK"]:
        separator = result["Value"]
      else:
        separator = ":::"
      pageNumber = 0
      numberOfJobs = 500
      if request.params.has_key("country") and len(request.params["country"]) > 0:
        if str(request.params["country"]) != "All":
          code = GeneralController().getCountriesReversed()
          tmpValue = str(request.params["country"]).split(separator)
          newValue = []
          for i in tmpValue:
            if code.has_key(i):
              newValue.append(code[i])
          req["Country"] = newValue
#          req["Country"] = str(request.params["country"]).split(separator)
      if request.params.has_key("site") and len(request.params["site"]) > 0:
        if str(request.params["site"]) != "All":
          req["Site"] = 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("maskstatus") and len(request.params["maskstatus"]) > 0:
        if str(request.params["maskstatus"]) != "All":
          req["MaskStatus"] = str(request.params["maskstatus"]).split(separator)
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
return getEmail
    email = getEmail[ "result" ]

    if not "subject" in request.params:
      result = "subject parameter is not in request... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }
    subject = GeneralController().checkUnicode( request.params[ "subject" ] )
    if not len( subject ) > 0:
      subject = "Message from %s" % email

    if not "msg" in request.params:
      result = "msg parameter is not in request... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }
    body = GeneralController().checkUnicode( request.params[ "msg" ] )
    if not len( body ) > 0:
      result = "Message body has zero length... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }

    users = list()
    userList = GeneralController().userlistFromRequest()
    gLogger.info( "List of users from request: %s" % userList )
    if userList:
      users.extend( userList )

    groupList = GeneralController().grouplistFromRequest()
    gLogger.info( "List of groups from request: %s" % groupList )
    if groupList:
      for i in groupList:
        userList = GeneralController().userlistFromGroup( i )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
result = "msg parameter is not in request... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }
    body = GeneralController().checkUnicode( request.params[ "msg" ] )
    if not len( body ) > 0:
      result = "Message body has zero length... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }

    users = list()
    userList = GeneralController().userlistFromRequest()
    gLogger.info( "List of users from request: %s" % userList )
    if userList:
      users.extend( userList )

    groupList = GeneralController().grouplistFromRequest()
    gLogger.info( "List of groups from request: %s" % groupList )
    if groupList:
      for i in groupList:
        userList = GeneralController().userlistFromGroup( i )
        gLogger.info( "Get users: %s from group %s" % ( userList , i ) )
        if userList:
          users.extend( userList )
    gLogger.info( "Merged list of users from users and group %s" % users )

    if not len( users ) > 0:
      error = "Length of list of recipients is zero size"
      gLogger.info( error )
      return { "success" : "false" , "error" : error }
    users = uniqueElements( users )
    gLogger.info( "Final list of users to send message/mail: %s" % users )
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / SiteSummary.py View on Github external
gLogger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
    result = self.__request()
    gLogger.always( "getSiteSummaryWeb(%s,%s,%s,%s)" % (result,globalSort,pageNumber,numberOfJobs) )
    result = RPC.getSiteSummaryWeb(result,globalSort,pageNumber,numberOfJobs)
    gLogger.always("\033[0;31m YO: \033[0m",result)
    if result["OK"]:
      result = result["Value"]
      if result.has_key("TotalRecords") and  result["TotalRecords"] > 0:
        if result.has_key("ParameterNames") and result.has_key("Records"):
          if len(result["ParameterNames"]) > 0:
            if len(result["Records"]) > 0:
              c.result = []
              jobs = result["Records"]
              head = result["ParameterNames"]
              headLength = len(head)
              countryCode = GeneralController().getCountries()
              for i in jobs:
                tmp = {}
                for j in range(0,headLength):
                  tmp[head[j]] = i[j]
                if countryCode.has_key(i[2]):
                  tmp["FullCountry"] = countryCode[i[2]]
                else:
                  tmp["FullCountry"] = "Unknown"
                c.result.append(tmp)
              total = result["TotalRecords"]
              if result.has_key("Extras"):
                extra = result["Extras"]
                c.result = {"success":"true","result":c.result,"total":total,"extra":extra}
              else:
                c.result = {"success":"true","result":c.result,"total":total}
            else:
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
subject = GeneralController().checkUnicode( request.params[ "subject" ] )
    if not len( subject ) > 0:
      subject = "Message from %s" % email

    if not "msg" in request.params:
      result = "msg parameter is not in request... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }
    body = GeneralController().checkUnicode( request.params[ "msg" ] )
    if not len( body ) > 0:
      result = "Message body has zero length... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }

    users = list()
    userList = GeneralController().userlistFromRequest()
    gLogger.info( "List of users from request: %s" % userList )
    if userList:
      users.extend( userList )

    groupList = GeneralController().grouplistFromRequest()
    gLogger.info( "List of groups from request: %s" % groupList )
    if groupList:
      for i in groupList:
        userList = GeneralController().userlistFromGroup( i )
        gLogger.info( "Get users: %s from group %s" % ( userList , i ) )
        if userList:
          users.extend( userList )
    gLogger.info( "Merged list of users from users and group %s" % users )

    if not len( users ) > 0:
      error = "Length of list of recipients is zero size"
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / SiteSummary.py View on Github external
s = list(result["Site"])
        tier1 = gConfig.getValue("/Website/PreferredSites",[])
        site = list()
        site.append(["All"])
        for i in tier1:
          site.append([str(i)])
        for i in s:
          if i not in tier1:
            site.append([str(i)])
      else:
        site = [["Error during RPC call"]]
      callback["site"] = site
      if result.has_key("Country") and len(result["Country"]) > 0:
        country = []
        country.append(["All"])
        countryCode = GeneralController().getCountries()
        for i in result["Country"]:
          if countryCode.has_key(i):
            j = countryCode[i]
          country.append([str(j)])
      else:
        country = [["Nothing to display"]]
      country.sort()
      callback["country"] = country
    else:
      callback["status"] = [["Error during RPC call"]]
      callback["gridtype"] = [["Error during RPC call"]]
      callback["maskstatus"] = [["Error during RPC call"]]
      callback["site"] = [["Error during RPC call"]]
      callback["country"] = [["Error during RPC call"]]
###
    return callback
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
if not len( body ) > 0:
      result = "Message body has zero length... aborting"
      gLogger.debug( result )
      return { "success" : "false" , "error" : result }

    users = list()
    userList = GeneralController().userlistFromRequest()
    gLogger.info( "List of users from request: %s" % userList )
    if userList:
      users.extend( userList )

    groupList = GeneralController().grouplistFromRequest()
    gLogger.info( "List of groups from request: %s" % groupList )
    if groupList:
      for i in groupList:
        userList = GeneralController().userlistFromGroup( i )
        gLogger.info( "Get users: %s from group %s" % ( userList , i ) )
        if userList:
          users.extend( userList )
    gLogger.info( "Merged list of users from users and group %s" % users )

    if not len( users ) > 0:
      error = "Length of list of recipients is zero size"
      gLogger.info( error )
      return { "success" : "false" , "error" : error }
    users = uniqueElements( users )
    gLogger.info( "Final list of users to send message/mail: %s" % users )
    
    if "email" in request.params:
      sendDict = GeneralController().getMailDict( users )
      return GeneralController().sendMail( sendDict , subject , body , email )
    return { "success" : "false" , "error" : result }
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
userList = GeneralController().userlistFromGroup( i )
        gLogger.info( "Get users: %s from group %s" % ( userList , i ) )
        if userList:
          users.extend( userList )
    gLogger.info( "Merged list of users from users and group %s" % users )

    if not len( users ) > 0:
      error = "Length of list of recipients is zero size"
      gLogger.info( error )
      return { "success" : "false" , "error" : error }
    users = uniqueElements( users )
    gLogger.info( "Final list of users to send message/mail: %s" % users )
    
    if "email" in request.params:
      sendDict = GeneralController().getMailDict( users )
      return GeneralController().sendMail( sendDict , subject , body , email )
    return { "success" : "false" , "error" : result }
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / systems / SystemAdministration.py View on Github external
def __returnEmail( self ):
  
    """
    Return email of owner of the request as JSON structure
    """

    email = GeneralController().getRequesterEmail()
    if not email:
      error = "Can't get e-mail from CS"
      gLogger.error( error )
      return { "success" : "false" , "error" : error }
    return { "success" : "true" , "result" : email }