Exemplo n.º 1
0
 def connect(self, ipPort, version):
     path = "connect"
     self.httpClient.setIpPort(ipPort)
     retdic = self.httpClient.post(path, {
         "clientid": str(self.clientid),
         "version": version
     })
     try:
         if "需要版本" in retdic["msg"]:
             retdic["当前版本"] = version
         self.clientid = retdic["msg"]["clientid"]
     except Exception as e:
         logger.info(str(e))
     return retdic
Exemplo n.º 2
0
    def buildMstruct(self):
        "处理mapList中的结构列到mstruct Map"
        for line in self.mapList:
            if "类型" not in line or "名称" not in line or "结构" not in line:
                continue
            type = line["类型"]
            name = line["名称"]
            space = line["空间"] if "空间" in line else None
            if space:
                self.mapSpaceDic[name] = space
            self.analysisLine(name, line["结构"])
            if type == "宏观执行":
                self.macList.append(name)
            elif type == "基础执行":
                if name not in self.map2Struct:
                    self.setFunc(红(f"[{name}]么有定义"))
                    continue
                dic = self.map2Struct[name]
                act = dic["执行"] if "执行" in dic else None
                if act and act not in self.allbase:
                    self.allbase.append(act)
                elif not act:
                    self.setFunc(红(f"[{name}]么有执行"))
                    continue

        logger.info(f"self.mapSpaceDic:{self.mapSpaceDic}")
        logger.info(f"self.map2Struct:{self.map2Struct}")
        logger.info(f"self.qsBindlist:{self.qsBindlist}")
        logger.info(f"self.rfBindlist:{self.rfBindlist}")
Exemplo n.º 3
0
 def send(self, text):
     "发送内容"
     tt = str(text).strip(" \n    \r")
     if len(tt) == 0:
         text = 青(f"AI:") + 红(f"发送消息为空")
         self.setKnowtxt(self.msgTedit, text)
         return
     logger.info(f"发送:{text}")
     self.sendMsgList.append(text)
     ret = self.exUtil.sendMsg(text)
     text = 青(f"{self.clientid}:") + 蓝(f"{text}")
     self.setKnowtxt(self.msgTedit, text)
     text = 青(f"{self.clientid}:") + 蓝(f"{ret}")
     self.setKnowtxt(self.msgTedit, text)
     self.ledit.clear()
Exemplo n.º 4
0
 def post(self, math: str, msgdic: dict):
     try:
         head = {"Content-Type": "application/json"}
         lmath = math.strip("/")
         lurl = f"{self.url}/{lmath}"
         logger.info(f"url:{lurl},reqs:{msgdic}")
         rp = requests.post(lurl, data=msgdic, headers=head)
         logger.info(f"resp:{rp.text}")
         return eval(rp.text)
     except Exception as e:
         traceback.print_exc()
         logger.info(f"error:{e}")
         return {"error": str(e)}
Exemplo n.º 5
0
    def buildTargetListSpaceDict(self, target_list, fields):
        for line in target_list:
            for item in fields:
                if item not in line:
                    self.setFunc(红(f"导入文件位格不对,缺少需要{item}"))
                    return False
            self.mapSpaceDic[line["名称"]] = line["空间"]
            self.analysisLine(line["名称"], line["结构"])

        logger.info(f"self.mapSpaceDic:{self.mapSpaceDic}")
        logger.info(f"self.map2Struct:{self.map2Struct}")
        logger.info(f"self.rfBindlist:{self.rfBindlist}")
        return True
Exemplo n.º 6
0
 def UpText(self, content):
     logger.info(content)
Exemplo n.º 7
0
 def analysisRespSheet(self, sheet: sheet.Sheet):
     "解析反应模式 sheet"
     sheetlist = self.analysisSheet2List(sheet, self.respfieldName)
     self.respList += sheetlist
     logger.info(f"self.respList:{self.respList}")
Exemplo n.º 8
0
 def analysisGeneralizeSheet(self, sheet):
     "解析泛化 sheet"
     sheetlist = self.analysisSheet2List(sheet, self.generalizefieldName)
     self.generalList += sheetlist
     logger.info(f"self.generalizeList:{self.generalList}")
Exemplo n.º 9
0
 def analysisStatSheet(self, sheet):
     "解析统计sheet"
     sheetlist = self.analysisSheet2List(sheet, self.mapfieldName)
     self.statList += sheetlist
     logger.info(f"self.statList: {self.statList}")
Exemplo n.º 10
0
 def analysisKnowsSheet(self, sheet):
     "解析知识 sheet"
     sheetlist = self.analysisSheet2List(sheet, self.mapfieldName)
     self.knowledgeList += sheetlist
     logger.info(f"self.knowledgeList:{self.knowledgeList}")
Exemplo n.º 11
0
        sendmsg = {"clientid": str(self.clientid)}
        retdic = self.httpClient.post(path, sendmsg)
        return self.parseRet(retdic)

    def addKnow(self, ivs, spaceid):
        "增加知识"
        path = "addKnow"
        retdic = self.httpClient.post(path, {
            "ivs": ivs,
            "spaceid": spaceid,
            "clientid": str(self.clientid)
        })
        return self.parseRet(retdic)

    def restartTest(self):
        "重新开始测试"
        path = "restartTest"
        retdic = self.httpClient.post(path, {"clientid": str(self.clientid)})
        return self.parseRet(retdic)


if __name__ == '__main__':
    myexl = myExcel("/home/jgb/MTS/respClient/0825_resp.xlsx")
    strin = "主语=自身,执行=生成约束,对象=?25,空间=“具体对象”,内容=(主语=?25,属类=文章)"
    strin = myexl.transF2H(strin)
    ret = myexl.split2Dic("aa", strin)
    # ret = myexl.getAllBas()
    logger.info(ret)
    # # ret = myexl.transF2H("(主语=自身,执行=发送,内容=((主语=自身,执行=祈使检测,执行状态=完成))")
    # myexl.analysisLine("test",ret)