Exemplo n.º 1
0
    def run(self):
        start = time.time()
        logging.info(
            "Send rpc start, service: {}, method: {}, params: {}, waiting result......".format(
                self.service, self.method, self.params
            )
        )
        try:
            result = getattr(getattr(self.client, self.service), self.method)(**self.params)
        except Exception as e:
            result = utils.errorToDict(repr(e))
            logging.exception(e)

        data = {
            const.NODE_PROJECT: self.project,
            const.NODE_SERVICE: self.service,
            const.NODE_MODULE: self.module,
            const.NODE_METHOD: self.method,
            const.PARAMS: self.params,
            const.RESULT: result,
        }
        end = time.time()
        data = utils.objectToJsonStr(data)
        logging.info(
            "Send rpc end, calling time: {}, project: {}, service: {}, method: {}, params:{}, result: {}".format(
                end-start, self.project, self.service, self.method, utils.objectToJsonStr(self.params), utils.objectToJsonStr(result)
            )
        )

        self.finishSignal.emit(data)
Exemplo n.º 2
0
    def onClickedNode(self, info):
        """
        显示鼠标选择节点数据
        """
        self.serviceEdit.setText(info.get(const.NODE_SERVICE, ""))
        self.methodEdit.setText(info.get(const.NODE_METHOD, ""))
        params = info.get(const.PARAMS, {})
        result = info.get(const.RESULT, {})
        if params is not None:
            self.paramsEdit.setText(utils.objectToJsonStr(params))
        if result is not None:
            self.showResult(utils.objectToJsonStr(result))

        self.nodeInfo = info
Exemplo n.º 3
0
 def getNodeInfo(self):
     info = {
         const.NODE_PROJECT: self.project,
         const.NODE_SERVICE: self.service,
         const.NODE_MODULE: self.module,
         const.NODE_METHOD: self.method,
         const.PARAMS: self.getParams(),
         const.RESULT: self.getResult(),
         const.NODE_TYPE: self.getType()
     }
     logging.info("TreeNode info: {}".format(utils.objectToJsonStr(info)))
     return info
Exemplo n.º 4
0
 def onSendRpcFinished(self, data: str):
     data = json.loads(data)
     result = utils.objectToJsonStr(data["result"])
     if len(result) > const.MAX_LENGTH:
         result = result[:const.MAX_LENGTH]
         result += "...... Sorry, the result is too long. Please check the log for whole result."
     self.showResult(result)
     self.unlockSendButton()
     if "error" not in result.lower() and len(result) < const.MAX_LENGTH:
         storage.updateResut(
             data[const.NODE_PROJECT],
             data[const.NODE_SERVICE],
             data[const.NODE_MODULE],
             data[const.NODE_METHOD],
             data["result"]
         )
Exemplo n.º 5
0
 def loggingData(self):
     logging.info("Storage data: {}".format(
         utils.objectToJsonStr(self.getData())))
Exemplo n.º 6
0
 def save(self):
     with open(self.path, "w", encoding="utf-8") as f:
         f.write(utils.objectToJsonStr(self.data))