Example #1
0
    def get(self, msgInfo):
        #提取消息内容
        msgInfo = myData_Trans.Tran_ToDict(msgInfo)
        imgPath = msgInfo.get('imgPath', "").replace("☀", "/")
        usrName = msgInfo.get('usrName', "")
        urlCallback = msgInfo.get('urlCallback', "")
        if (imgPath == "" or usrName == ""):
            return {"err": -1}

            #发送wx消息,wx处理
            pMMsg = gol._Get_Setting('manageMsgs')
            if (pMMsg != None):
                bufMsgs = gol._Get_Setting('bufferMsgs')  #消息缓存
                id = len(bufMsgs.usrMsgs) + 1
                msgID = "*" + str(id)

                msg = pMMsg.OnCreatMsg()
                msg["usrPlat"] = "wx"
                msg["usrName"] = usrName
                msg["bufTimes"] = 2

                #发送标识信息
                msg["msgType"] = "TEXT"
                msg["msg"] = "@*" + msgID + " "
                pMMsg.OnHandleMsg(msg)

                #发送验证码图片信息
                #imgPath = "E:\\myCode\\zxcProj\\src\\Zxc.Python\\zxcPy.gsLog_Submits\\code.jpg"
                msg["msgType"] = "IMAGE"
                msg["msg"] = imgPath
                pMMsg.OnHandleMsg(msg)

                return {"res": "OK", "msgID": msgID}
            else:
                return {"err": 0}
Example #2
0
    def get(self):
        #提取股票信息
        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        pRisks = gol._Get_Value('zxcRisk_Control', None)
        bResult = True

        # 组装参数并添加
        #dicParam = {"边界限制": True,"定量监测": False, "监测间隔": 0.01,"止盈线": 0.20, "止损线": -0.05, "动态止盈": True, "动态止损": True, "止盈回撤": 0.01, "止盈比例": 0.20, "止损回撤": 0.01, "止损比例": 0.20 }
        usrID = request.args.get('usrID', '')
        usrTag = request.args.get('usrTag', '')
        code_id = request.args.get('code_id', "")
        code_name = request.args.get('code_name', "")
        removeSet = myData_Trans.To_Bool(request.args.get('removeSet', False))
        paramInfo = myData_Trans.Tran_ToDict(request.args.get('setInfo', "{}"))
        paramInfo['removeSet'] = removeSet

        dtTrade = request.args.get('time', "")
        dateTag = request.args.get('dateTag', "")
        stockPrice = myData_Trans.To_Float(
            str(request.args.get('stockPrice', 0)))
        stockNum = myData_Trans.To_Int(str(request.args.get('stockNum', 0)))
        if (removeSet == False and (stockPrice == 0 or stockNum == 0)):
            bResult = False
            pMsg['text'] = "股价、数量不能为0."
        if (usrID == "" and usrTag == ""):
            bResult = False
            pMsg['text'] = "用户信息不能为空."
        if (bResult):
            strR = pRisks.addRiskSet(usrID, usrTag, code_id, code_name,
                                     stockPrice, stockNum, dtTrade, dateTag,
                                     paramInfo)

        #解析参数
        strTag = "风控设置:" + code_name + "\n"
        if (bResult):
            if (removeSet == False):
                if (stockPrice == 0 or stockNum == 0):
                    pMsg['text'] = strTag + " --已成功修改参数信息."
                else:
                    trade = myData.iif(stockNum > 0, "买入", "卖出")
                    if (stockNum % 100 == 0):
                        pMsg[
                            'text'] = strTag + F"新增{trade}:{str(abs(stockNum))} 股.\n{trade}均价:{stockPrice} 元/股)."
                    else:
                        pMsg[
                            'text'] = strTag + F"新增{trade}:{str(abs(stockNum))} 张.\n{trade}均价:{stockPrice} 元/张."
                bResult = True
            else:
                pMsg['text'] = strTag + " --设置已成功移除."
                bResult = True
        pMsg['result'] = bResult
        if (bResult == ""): pMsg['text'] = strTag + "操作失败!"
        return pMsg
Example #3
0
 def Init_UserInfo(self, usrName, usrNameNick, usrID):
     if (usrName == "zxcRobot" and usrID == "zxcRobotID"
             and usrNameNick == "zxc机器人"):
         strDir, strName = myIO.getPath_ByFile(__file__)
         strDir_Base = os.path.abspath(os.path.join(strDir, "../../.."))
         content = myIO.getContent(
             strDir_Base + '\zxcPy.Weixin\Data\zxcWeixin.cache', True,
             False, True)
         if (content != ""):
             dictUser = myData_Trans.Tran_ToDict(content)
             self.usrName = usrName
             self.usrNameNick = dictUser.get("NickName", "zxc机器人")  #归属用户昵称
             self.usrID = dictUser.get("UserName", "zxcRobotID")  #归属用户昵称
     gol._Set_Setting('usrName', self.usrName)
     gol._Set_Setting('usrNameNick', self.usrNameNick)
     gol._Set_Setting('usrID', self.usrID)
     self.Init()
Example #4
0
    def Login_getCaptcha(self, imgPath, useLoacal=False):
        if (useLoacal):
            captcha_code = input("输入验证码:")
        else:
            # 读取图片文件
            img_str = myIO.getImage_Str(imgPath)
            if (img_str == ""):
                return ""
            else:
                # 调用API,人工识别验证码
                pWeb = myWeb("http://39.105.196.175:8668")

                # 组装请求参数
                req = {
                    "params": {
                        "imgName": myIO.getFileName(imgPath, False),
                        "imgData": img_str,
                        "usrName": "茶叶一主号"
                    }
                }

                # 调用API,轮询请求打码结果
                r = pWeb.Do_Post("zxcAPI/robot/captcha_img", req, "验证码", True,
                                 True, True)
                res = myData_Trans.Tran_ToDict(r.decode())
                if (res.get("res", "" == "OK")):
                    msgID = res['msgID']
                    ind = 0

                    # 轮询调用API
                    while (True):
                        # 轮询提取人工识别结果
                        r = pWeb.Do_API_get(
                            F"zxcAPI/robot/captcha/code/{msgID}",
                            "验证码结果").strip().replace("\"", "")
                        if (r != ""):
                            lstR = r.split(',')
                            captcha_code = lstR[len(lstR) - 1]
                            break

                        # 超时检测
                        if (ind > 60): return False
                        ind += 1
                        time.sleep(3)
        return captcha_code
Example #5
0
    def get(self):
        #提取股票信息
        extype = request.args.get('extype', "")
        code_id = request.args.get('code_id', "")
        code_name = request.args.get('code_name', "")
        removeSet = myData_Trans.To_Bool(request.args.get('removeSet', ''))

        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        pStocks = gol._Get_Value('setsStock', None)
        lstStock = pStocks._Find(code_id, "", exType=extype)
        if (len(lstStock) != 1):
            pMsg['text'] = "股票代码或名称错误!"
            return pMsg
        pStock = lstStock[0]
        strTag = "股票设置:" + pStock.code_name + "\n      "

        #解析参数
        bResult = False
        if (bResult == False):
            #提取行情对象
            pSource = gol._Get_Value('quoteSource', None)
            pSets = gol._Get_Value('setsQuote', None)
            if (pSource != None and pSets != None):
                if (removeSet == False):
                    editInfo = myData_Trans.Tran_ToDict(
                        request.args.get('editInfo', "{}"))
                    if (pSets._Edit(pStock.extype, pStock.code_id,
                                    pStock.code_name, editInfo)):
                        pSource.params = pSource._getDefault_Param()
                        pMsg['text'] = strTag + " --设置已成功修改。"
                        bResult = True
                        print(pSource.params)
                else:
                    usrID = request.args.get('usrID', '')
                    usrPlat = request.args.get('usrPlat', 'wx')
                    if (pSets._Remove(pStock.extype, pStock.code_id,
                                      pStock.code_name, usrID)):
                        pSource.params = pSource._getDefault_Param()
                        pMsg['text'] = strTag + " --设置已成功移除。"
                        bResult = True
                        print(pSource.params)
        pMsg['result'] = bResult
        if (bResult == ""): pMsg['text'] = strTag + "操作失败!"
        return pMsg
    def _getIot_Info_Power(self, pIot):
        #使用BeautifulSoup解析代码,并锁定页码指定标签内容
        resp = self._DoWeb_Get(
            "查询电量", F"admin/card_opr/query_now/mid/{pIot.usrID}/q/power", {})
        soup = BeautifulSoup(resp.content.decode('unicode-escape'), 'lxml')

        #提取基本信息内容
        res = myData_Trans.Tran_ToDict(soup.find('p').string)
        if (res['state'] == 'fail'):
            return False
        elif (res['state'] == 'success'):
            baseInfo['当前总电量'] = divs[1].find('label').string
            baseInfo['电量同步时间'] = divs[1].find('font').string

        info: "已成功添加任务 <br>&nbsp;&nbsp;请稍后刷新本页面或打开下方手动抄表界面等待抄表结果"
        #提取行数据
        baseInfo = pIot.iotInfo
        baseInfo['当前总电量'] = divs[1].find('label').string
        baseInfo['电量同步时间'] = divs[1].find('font').string
        return baseInfo
Example #7
0
    def post(self):
        args = myWeb.parser.parse_args()
        params = myData_Trans.Tran_ToDict(args['params'])

        # 解码得到图像
        img_str = params['imgData']
        img_decode = myIO.getImage_Byte(img_str)

        #保存图片
        if (img_str != ""):
            imgPath = self.Dir_Image + params['imgName']
            usrName = params.get('usrName', "茶叶一主号")
            with open(imgPath, 'wb') as f:
                f.write(img_decode)

            #发送wx消息
            pMMsg = gol._Get_Setting('manageMsgs')
            if (pMMsg != None):
                bufMsgs = gol._Get_Setting('bufferMsgs')  #消息缓存
                id = len(bufMsgs.usrMsgs) + 1
                msgID = "*" + str(id)

                msg = pMMsg.OnCreatMsg()
                msg["usrPlat"] = "wx"
                msg["usrName"] = usrName
                msg["bufTimes"] = 2

                #发送标识信息
                msg["msgType"] = "TEXT"
                msg["msg"] = "@*" + msgID + " "
                pMMsg.OnHandleMsg(msg)

                #发送验证码图片信息
                #imgPath = "E:\\myCode\\zxcProj\\src\\Zxc.Python\\zxcPy.gsLog_Submits\\code.jpg"
                msg["msgType"] = "IMAGE"
                msg["msg"] = imgPath
                pMMsg.OnHandleMsg(msg)

                return {"res": "OK", "msgID": msgID}
            else:
                return {"err": 0}
Example #8
0
    def _Init_BySet_str(self, strSet):
        strSets = strSet.split(',')
        if (len(strSets) < 10): return False

        #初始设置集
        ids = strSets[0].split('.')
        pSet = self._Find("", ids[0] + ids[1])
        if (pSet == None):
            pSet = myQuote_Settings(ids[0], ids[1], "", "")
            self._Index(pSet)

        #按类型初始
        if (pSet):
            monitorTag = strSets[5]
            pSetting = pSet.settings.get(monitorTag, None)
            if (pSetting == None):
                if (monitorTag == "整点播报" or monitorTag == "涨跌监测"):  #特殊类型处理
                    pSetting = myQuote_Setting(monitorTag)
                else:
                    pSetting = None
                    return False

            #底层属性提取
            pSetting.monitorTag = monitorTag
            pSetting.isValid = myData_Trans.To_Bool(strSets[6])
            pSetting.setStr = strSets[7]
            pSetting.mark = strSets[9]
            msgUsers = myData_Trans.Tran_ToDict(strSets[8].replace(',', ','))
            for x in msgUsers:
                pSetting.msgUsers[x] = msgUsers[x]

                # 特殊同步设置
                if (x == "茶叶一主号"):
                    pSetting.msgUsers["老婆"] = msgUsers[x]
            pSet.AddSetting(pSetting)
            self._Index_User(pSet)
            return True
        return False