How to use DIRAC - 10 common examples

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 / production / ProductionRequest.py View on Github external
  @jsonify
  def bkk_tags(self):
    try:
      tag = str(request.params.get('tag', ''))
      tags = tag.split(':')
      RPC = getRPCClient('Bookkeeping/BookkeepingManager')
      result = RPC.getAvailableTags()
      if not result['OK']:
        return result
      rows = [{'v':x[1]} for x in result['Value']['Records'] if x[0] in tags]
      return { 'OK':True, 'result':rows, 'total':len(rows) }
    except Exception, e:
      return S_ERROR('Could not get tags from BK (%s)' % str(e))
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
if not "JobAdministrator" in groupProperty and not "JobSharing" in groupProperty:
        if not request.params.has_key("globalStat"):
          req["Owner"] = str(user)
      else:
        if request.params.has_key("owner") and len(request.params["owner"]) > 0:
          if str(request.params["owner"]) != "All":
            req["Owner"] = str(request.params["owner"]).split(separator)
      if request.params.has_key("startDate") and len(request.params["startDate"]) > 0:
        if str(request.params["startDate"]) != "YYYY-mm-dd":
          if request.params.has_key("startTime") and len(request.params["startTime"]) > 0:
            req["FromDate"] = str(request.params["startDate"] + " " + request.params["startTime"])
          else:
            req["FromDate"] = str(request.params["startDate"])
      if request.params.has_key("endDate") and len(request.params["endDate"]) > 0:
        if str(request.params["endDate"]) != "YYYY-mm-dd":
          if request.params.has_key("endTime") and len(request.params["endTime"]) > 0:
            req["ToDate"] = str(request.params["endDate"] + " " + request.params["endTime"])
          else:
            req["ToDate"] = str(request.params["endDate"])
      if request.params.has_key("date") and len(request.params["date"]) > 0:
        if str(request.params["date"]) != "YYYY-mm-dd":
          req["LastUpdate"] = str(request.params["date"])
      if request.params.has_key("sort") and len(request.params["sort"]) > 0:
        globalSort = str(request.params["sort"])
        key,value = globalSort.split(" ")
        globalSort = [[str(key),str(value)]]
      else:
        globalSort = [["JobID","DESC"]]
    gLogger.always("REQUEST:",req)
    return req
################################################################################
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
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:
        if str(request.params["minorstat"]) != "All":
          req["MinorStatus"] = str(request.params["minorstat"]).split(separator)
      if request.params.has_key("app") and len(request.params["app"]) > 0:
        if str(request.params["app"]) != "All":
          req["ApplicationStatus"] = str(request.params["app"]).split(separator)
      if request.params.has_key("types") and len(request.params["types"]) > 0:
        if str(request.params["types"]) != "All":
          req["JobType"] = str(request.params["types"]).split(separator)
      if not "JobAdministrator" in groupProperty and not "JobSharing" in groupProperty:
        if not request.params.has_key("globalStat"):
          req["Owner"] = str(user)
      else:
        if request.params.has_key("owner") and len(request.params["owner"]) > 0:
          if str(request.params["owner"]) != "All":
            req["Owner"] = str(request.params["owner"]).split(separator)
      if request.params.has_key("startDate") and len(request.params["startDate"]) > 0:
        if str(request.params["startDate"]) != "YYYY-mm-dd":
          if request.params.has_key("startTime") and len(request.params["startTime"]) > 0:
            req["FromDate"] = str(request.params["startDate"] + " " + request.params["startTime"])
          else:
            req["FromDate"] = str(request.params["startDate"])
      if request.params.has_key("endDate") and len(request.params["endDate"]) > 0:
        if str(request.params["endDate"]) != "YYYY-mm-dd":
          if request.params.has_key("endTime") and len(request.params["endTime"]) > 0:
            req["ToDate"] = str(request.params["endDate"] + " " + request.params["endTime"])
          else:
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
id = request.params["reschedule"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__rescheduleJobs(id)
    elif request.params.has_key("reset") and len(request.params["reset"]) > 0:
      id = request.params["reset"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__resetJobs(id)
    elif request.params.has_key("pilotStdOut") and len(request.params["pilotStdOut"]) > 0:
      id = request.params["pilotStdOut"]
      return self.__pilotGetOutput("out",int(id))
    elif request.params.has_key("pilotStdErr") and len(request.params["pilotStdErr"]) > 0:
      id = request.params["pilotStdErr"]
      return self.__pilotGetOutput("err",int(id))
    elif request.params.has_key("LogURL") and len(request.params["LogURL"]) > 0:
      id = request.params["LogURL"]
      return self.__pilotGetURL(int(id))
    elif request.params.has_key("getStagerReport") and len(request.params["getStagerReport"]) > 0:
      id = request.params["getStagerReport"]
      return self.__getStagerReport(int(id))
    elif request.params.has_key("getSandBox") and len(request.params["getSandBox"]) > 0:
      id = request.params["getSandBox"]
      return self.__getSandBox(int(id))
    elif request.params.has_key("refreshSelection") and len(request.params["refreshSelection"]) > 0:
      return self.__getSelectionData()
    elif request.params.has_key("getStat") and len(request.params["getStat"]) > 0:
      selector = str(request.params["getStat"])
      return self.__getStats(selector)
    elif request.params.has_key("globalStat"):
      return self.__globalStat()
    elif request.params.has_key("getPageOptions") and len(request.params["getPageOptions"]) > 0:
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
return self.__getStandardOutput(id)
    elif request.params.has_key("getBasicInfo") and len(request.params["getBasicInfo"]) > 0:
      id = int(request.params["getBasicInfo"])
      return self.__getBasicInfo(id)
    elif request.params.has_key("LoggingInfo") and len(request.params["LoggingInfo"]) > 0:
      id = int(request.params["LoggingInfo"])
      return self.__getLoggingInfo(id)
    elif request.params.has_key("getParams") and len(request.params["getParams"]) > 0:
      id = int(request.params["getParams"])
      return self.__getParams(id)
    elif request.params.has_key("delete") and len(request.params["delete"]) > 0:
      id = request.params["delete"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__delJobs(id)
    elif request.params.has_key("kill") and len(request.params["kill"]) > 0:
      id = request.params["kill"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__killJobs(id)
    elif request.params.has_key("reschedule") and len(request.params["reschedule"]) > 0:
      id = request.params["reschedule"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__rescheduleJobs(id)
    elif request.params.has_key("reset") and len(request.params["reset"]) > 0:
      id = request.params["reset"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__resetJobs(id)
    elif request.params.has_key("pilotStdOut") and len(request.params["pilotStdOut"]) > 0:
      id = request.params["pilotStdOut"]
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
req = {}
    group = credentials.getSelectedGroup()
    user = str(credentials.getUsername())
    global pageNumber
    global numberOfJobs
    global globalSort
    if request.params.has_key("limit") and len(request.params["limit"]) > 0:
      numberOfJobs = int(request.params["limit"])
      if request.params.has_key("start") and len(request.params["start"]) > 0:
        pageNumber = int(request.params["start"])
      else:
        pageNumber = 0
    else:
      numberOfJobs = 25
      pageNumber = 0
    if request.params.has_key("id") and len(request.params["id"]) > 0:
      testString = str(request.params["id"])
      testString = testString.strip(';, ')
      testString = testString.split(', ')
      if len(testString) == 1:
        testString = testString[0].split('; ')
        if len(testString) == 1:
          testString = testString[0].split(' ')
          if len(testString) == 1:
            testString = testString[0].split(',')
            if len(testString) == 1:
              testString = testString[0].split(';')
              if len(testString) == 1:
                req["JobID"] = testString[0]
              else:
                req["JobID"] = testString
            else:
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
id = [int(i) for i in id ]
      return self.__killJobs(id)
    elif request.params.has_key("reschedule") and len(request.params["reschedule"]) > 0:
      id = request.params["reschedule"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__rescheduleJobs(id)
    elif request.params.has_key("reset") and len(request.params["reset"]) > 0:
      id = request.params["reset"]
      id = id.split(",")
      id = [int(i) for i in id ]
      return self.__resetJobs(id)
    elif request.params.has_key("pilotStdOut") and len(request.params["pilotStdOut"]) > 0:
      id = request.params["pilotStdOut"]
      return self.__pilotGetOutput("out",int(id))
    elif request.params.has_key("pilotStdErr") and len(request.params["pilotStdErr"]) > 0:
      id = request.params["pilotStdErr"]
      return self.__pilotGetOutput("err",int(id))
    elif request.params.has_key("LogURL") and len(request.params["LogURL"]) > 0:
      id = request.params["LogURL"]
      return self.__pilotGetURL(int(id))
    elif request.params.has_key("getStagerReport") and len(request.params["getStagerReport"]) > 0:
      id = request.params["getStagerReport"]
      return self.__getStagerReport(int(id))
    elif request.params.has_key("getSandBox") and len(request.params["getSandBox"]) > 0:
      id = request.params["getSandBox"]
      return self.__getSandBox(int(id))
    elif request.params.has_key("refreshSelection") and len(request.params["refreshSelection"]) > 0:
      return self.__getSelectionData()
    elif request.params.has_key("getStat") and len(request.params["getStat"]) > 0:
      selector = str(request.params["getStat"])
      return self.__getStats(selector)
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
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:
        if str(request.params["minorstat"]) != "All":
          req["MinorStatus"] = str(request.params["minorstat"]).split(separator)
      if request.params.has_key("app") and len(request.params["app"]) > 0:
        if str(request.params["app"]) != "All":
          req["ApplicationStatus"] = str(request.params["app"]).split(separator)
      if request.params.has_key("types") and len(request.params["types"]) > 0:
        if str(request.params["types"]) != "All":
          req["JobType"] = str(request.params["types"]).split(separator)
      if not "JobAdministrator" in groupProperty and not "JobSharing" in groupProperty:
        if not request.params.has_key("globalStat"):
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / JobMonitor.py View on Github external
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:
        if str(request.params["minorstat"]) != "All":
          req["MinorStatus"] = str(request.params["minorstat"]).split(separator)
      if request.params.has_key("app") and len(request.params["app"]) > 0:
        if str(request.params["app"]) != "All":
          req["ApplicationStatus"] = str(request.params["app"]).split(separator)
      if request.params.has_key("types") and len(request.params["types"]) > 0:
        if str(request.params["types"]) != "All":
          req["JobType"] = str(request.params["types"]).split(separator)
      if not "JobAdministrator" in groupProperty and not "JobSharing" in groupProperty:
        if not request.params.has_key("globalStat"):
          req["Owner"] = str(user)
      else:
        if request.params.has_key("owner") and len(request.params["owner"]) > 0:
          if str(request.params["owner"]) != "All":
            req["Owner"] = str(request.params["owner"]).split(separator)
      if request.params.has_key("startDate") and len(request.params["startDate"]) > 0:
        if str(request.params["startDate"]) != "YYYY-mm-dd":
          if request.params.has_key("startTime") and len(request.params["startTime"]) > 0:
            req["FromDate"] = str(request.params["startDate"] + " " + request.params["startTime"])
github DIRACGrid / -obsolete-DIRACWeb / dirac / controllers / jobs / PilotMonitor.py View on Github external
def submit(self):
    pagestart = time()
    lhcbGroup = credentials.getSelectedGroup()
    if lhcbGroup == "visitor":
      c.result = {"success":"false","error":"You are not authorised"}
      return c.result
    RPC = getRPCClient("WorkloadManagement/WMSAdministrator")
    result = self.__request()
    result = RPC.getPilotMonitorWeb(result,globalSort,pageNumber,numberOfJobs)
    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)