Exemple #1
0
  def web_getTransformationData(self):

    pagestart = Time.time()
    callback = None
    sData = self.getSessionData()
    callback = {}
    user = sData["user"]["username"]
    if user == "Anonymous":
      callback = {"success":"false","error":"You are not authorised"}
    else:
      RPC = RPCClient("Transformation/TransformationManager")
      result = self.__request()
      
      result = yield self.threadTask(RPC.getTransformationSummaryWeb, result, self.globalSort, self.pageNumber, self.numberOfJobs)
      if not result["OK"]:
        self.finish(json.dumps({"success":"false", "error":result["Message"]}))
        return

      result = result["Value"]

      if not result.has_key("TotalRecords"):
        self.finish(json.dumps({"success":"false", "result":"", "error":"Data structure is corrupted"}))
        return

      if not (result["TotalRecords"] > 0):
        self.finish(json.dumps({"success":"false", "result":"", "error":"There were no data matching your selection"}))
        return


      if not (result.has_key("ParameterNames") and result.has_key("Records")):
        self.finish(json.dumps({"success":"false", "result":"", "error":"Data structure is corrupted"}))
        return

      if not (len(result["ParameterNames"]) > 0):
        self.finish(json.dumps({"success":"false", "result":"", "error":"ParameterNames field is missing"}))
        return

      if not (len(result["Records"]) > 0):
        self.finish(json.dumps({"success":"false", "Message":"There are no data to display"}))
        return

      callback = []
      jobs = result["Records"]
      head = result["ParameterNames"]
      headLength = len(head)
      for i in jobs:
        tmp = {}
        for j in range(0,headLength):
          tmp[head[j]] = i[j]
        callback.append(tmp)
      total = result["TotalRecords"]
      if "Extras" in result:
        gLogger.info(result["Extras"])
        extra = result["Extras"]
        timestamp = Time.dateTime().strftime("%Y-%m-%d %H:%M [UTC]")
        callback = {"success":"true","result":callback,"total":total,"extra":extra, "date":timestamp}
      else:
        callback = {"success":"true","result":callback,"total":total, "date":None}

      gLogger.info("\033[0;31m PRODUCTION SUBMIT REQUEST: \033[0m %s" % (Time.time() - pagestart))
    self.finish(json.dumps(callback))
Exemple #2
0
    def web_getTransformationData(self):

        pagestart = Time.time()
        sData = self.getSessionData()
        callback = {}
        user = sData["user"]["username"]

        tsClient = TransformationClient(timeout=3600)

        if user == "Anonymous":
            callback = {"success": "false", "error": "You are not authorised"}
        else:
            result = self.__request()

            result = yield self.threadTask(
                tsClient.getTransformationSummaryWeb, result, self.globalSort,
                self.pageNumber, self.numberOfJobs)
            if not result["OK"]:
                self.finish(
                    json.dumps({
                        "success": "false",
                        "error": result["Message"]
                    }))
                return

            result = result["Value"]

            if "TotalRecords" not in result:
                self.finish(
                    json.dumps({
                        "success": "false",
                        "result": "",
                        "error": "Data structure is corrupted"
                    }))
                return

            if result["TotalRecords"] < 1:
                self.finish(
                    json.dumps({
                        "success":
                        "false",
                        "result":
                        "",
                        "error":
                        "There were no data matching your selection"
                    }))
                return

            if "ParameterNames" not in result and "Records" not in result:
                self.finish(
                    json.dumps({
                        "success": "false",
                        "result": "",
                        "error": "Data structure is corrupted"
                    }))
                return

            if len(result["ParameterNames"]) < 1:
                self.finish(
                    json.dumps({
                        "success": "false",
                        "result": "",
                        "error": "ParameterNames field is missing"
                    }))
                return

            if len(result["Records"]) < 1:
                self.finish(
                    json.dumps({
                        "success": "false",
                        "Message": "There are no data to display"
                    }))
                return

            callback = []
            jobs = result["Records"]
            head = result["ParameterNames"]
            headLength = len(head)
            for i in jobs:
                tmp = {}
                for j in range(0, headLength):
                    tmp[head[j]] = i[j]
                callback.append(tmp)
            total = result["TotalRecords"]
            if "Extras" in result:
                gLogger.info(result["Extras"])
                extra = result["Extras"]
                timestamp = Time.dateTime().strftime("%Y-%m-%d %H:%M [UTC]")
                callback = {
                    "success": "true",
                    "result": callback,
                    "total": total,
                    "extra": extra,
                    "date": timestamp
                }
            else:
                callback = {
                    "success": "true",
                    "result": callback,
                    "total": total,
                    "date": None
                }

            gLogger.info("\033[0;31m PRODUCTION SUBMIT REQUEST: \033[0m %s" %
                         (Time.time() - pagestart))
        self.finish(json.dumps(callback))