示例#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}
示例#2
0
    def _Done_Text(self, Text, msgID="", usrInfo={}):
        #提取命令内容
        if (Text.count("@*") != 1): return ""
        cmds = Text.strip()[2:].split(" ")
        cmd = cmds[0].strip()
        nNum = len(cmds)
        myDebug.Print(Text.strip())

        #账单命令处理
        strReturn = ""
        if (cmd == "帮助"):
            return self._Title_Helper()
        elif (cmd.count("*") == 1):
            #消息交互
            return self._Done_Text_Buffer(Text, "TEXT", usrInfo)
        elif (cmd == ""):
            #机器人
            return self.myRobot._Done(Text, msgID, "TEXT", usrInfo)
        elif (cmd == "股票"):
            #发送股票设置界面链接
            usrPlat, usrID = self._Done_Check_UserBack(usrInfo)
            url = gol._Get_Setting(
                "serverUrl"
            ) + 'zxcWebs/stock/quoteset/' + usrID + "/" + usrPlat
            strReturn = quote(url, safe=string.printable)  # unquote
        elif (cmd == "订单"):
            #发送订单相关界面链接
            usrPlat, usrID = self._Done_Check_UserBack(usrInfo)
            orderType = cmds[1].strip()
            url = gol._Get_Setting(
                "serverUrl"
            ) + 'zxcWebs/order/Add/' + orderType + "?usrID=" + usrID
            strReturn = quote(url, safe=string.printable)  # unquote
        return strReturn
示例#3
0
 def get(self, msgID):
     #提取消息内容
     bufMsgs = gol._Get_Setting('bufferMsgs')  #消息缓存
     pMsg = bufMsgs.Find(msgID)
     if (pMsg == None):
         return ""
     return myData_Trans.Tran_ToStr(pMsg.msg['value'])
示例#4
0
    def get(self):
        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        usrID = request.args.get('usrID', '')
        usrTag = request.args.get('usrTag', '')
        code_id = request.args.get('code_id', "")
        code_name = request.args.get('code_name', "")

        #初始返回组
        lstDate_Tag = []
        lstInfos = {}

        #查询及组装
        pRisks = gol._Get_Value('zxcRisk_Control', None)
        dictRisks = pRisks.getRisks(usrID,
                                    usrTag,
                                    code_id,
                                    code_name,
                                    bCheck=True)
        if (dictRisks != None):
            for x in dictRisks:
                pRisk = dictRisks[x]
                if (pRisk.setRisk.valid):
                    lstDate_Tag.append(x)
                    dictSet = pRisk.setRisk.Trans_ToDict().copy()
                    dictSet['操作时间'] = myData_Trans.Tran_ToDatetime_str(
                        dictSet['操作时间'], "%Y-%m-%d %H:%M:%S")
                    lstInfos[x] = dictSet

        jsonSetinfo = {}
        jsonSetinfo["dataTags"] = lstDate_Tag
        jsonSetinfo["setInfos"] = lstInfos

        pMsg['result'] = len(lstDate_Tag) > 0
        pMsg['text'] = jsonSetinfo
        return pMsg
示例#5
0
    def orderAdd_Updata(form, orderType):
        #记录账单
        pManager = gol._Get_Setting('manageBills', None)
        pBills = pManager[orderType]

        billInfo = pBills.OnCreat_BillInfo()
        billInfo['usrID'] = form.orderUsrName.data
        billInfo['usrBillType'] = "卖出"
        billInfo['recordTime'] = datetime.datetime.now()
        billInfo['recorder'] = form.recorderName.data
        billInfo['tradeID'] = ""
        billInfo['tradeID_Relation'] = ""
        billInfo['tradeParty'] = form.orderUsrName.data
        billInfo['tradeType'] = orderType
        billInfo['tradeTypeTarget'] = form.orderTargetType.data
        billInfo['tradeTarget'] = form.orderTarget.data
        billInfo['tradePrice'] = myData_Trans.To_Float(
            form.orderPrice.data.split(' ')[0].replace('¥', ''))
        billInfo['tradeNum'] = myData_Trans.To_Float(
            form.orderNum.data.split(' ')[0])
        billInfo['tradeMoney'] = myData_Trans.To_Float(
            form.orderMoney.data.replace('¥', ''))
        billInfo['tradePoundage'] = 0
        billInfo['tradeProfit'] = billInfo['tradeMoney']
        billInfo['tradeTime'] = datetime.datetime.now()
        billInfo['isDel'] = False
        billInfo['remark'] = form.orderRemark.data
        return pBills.Add_ByDict(billInfo)
示例#6
0
    def get(self):
        #提取爬虫设置信息 
        #?setInfo={'spiderName': "ceshi2", 'spiderTag': 'webPage', 'spiderUrl': "", "spiderRule": "", 'isValid':'False', 'isDel':'True', "timeSet" : "* * * * *", 'mark':'测试设置' }
        #?setInfo={'spiderName': "sh000001", 'spiderTag': 'quote', 'spiderUrl': "", "spiderRule": "", 'isValid':'True', 'isDel':'False', "timeSet" : "* 9-20 * * 1-6", 'mark':'测试设置' }
        params = request.args.get('setInfo', "{}")
        setInfo = myData_Json.Trans_ToJson(params)

        #setInfo = myData_Trans.Tran_ToDict(params)
        bRes = not (setInfo.get("spiderName", "") == "")
        bRemove = myData_Trans.To_Bool(setInfo.get('isDel', "False"))
        if(setInfo.get("timeSet", None) == None):
            setInfo['timeSet'] = "* 9-15 * * 1-5"
            
        if(bRes and bRemove):
            bRes = setsSpider._Remove(setInfo['spiderName'])
            bRes = setsSpider._Find(setInfo["spiderName"]) == None
        else:
            bRes = setsSpider._Edit(setInfo)
            
        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        if(bRes):
            pMsg['result'] = True
            spiderInfo = setsSpider._Find(setInfo["spiderName"])
            if(bRemove != True and spiderInfo != None):
                if(spiderInfo.isValid and not spiderInfo.isDeled):
                    pMsg['datas'] = [spiderInfo.ToDict()] 
        #return myData_Json.Trans_ToJson_str(pMsg)
        #使用jsonify来讲定义好的数据转换成json格式,并且返回给前端
        return jsonify(pMsg) 
示例#7
0
 def get(self):
     #载入配置
     code_id=request.args.get('code_id', "")
     code_name=request.args.get('code_name', "") 
     lstStock = stocksInfo._Find(code_id, code_name)
     
     lstExtypes = []
     lstCode_id = []
     lstCode_Name = []
     lstCode_NameEN = []
     for x in lstStock:
         lstExtypes.append(x.extype)
         lstCode_id.append(x.code_id)
         lstCode_Name.append(x.code_name)
         lstCode_NameEN.append(x.code_name_En)
         
     jsonStocks = myData_Json.Json_Object()
     jsonStocks["extypes"] = lstExtypes
     jsonStocks["code_ids"] = lstCode_id
     jsonStocks["code_names"] = lstCode_Name
     jsonStocks["code_namesEN"] = lstCode_NameEN
 
     pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
     pMsg['result'] = True
     pMsg['datas'] = jsonStocks._dict_
     #return myData_Json.Trans_ToJson_str(pMsg)
     #使用jsonify来讲定义好的数据转换成json格式,并且返回给前端
     return jsonify(pMsg) 
示例#8
0
    def get(self):
        # dataFrequency=1d&stockBars=1&stockTag="10003418.XSHG"
        # {'dataFrequency': "1d", 'datetimeStart': "2021-06-23 09:00:00", 'stockTag': "10003418.XSHG"}
        global quoteSource
        stockTag = request.args.get('queryID', "")
        dataFrequency = request.args.get('dataFrequency', "1d")
        params = {'dataFrequency': dataFrequency, 'stockTag': "10003418.XSHG"}
        
        stockBars = myData_Trans.To_Int(request.args.get('stockBars', "0"))
        if(stockBars > 0):
            params["stockBars"] = stockBars

        timeEnd = request.args.get('datetimeEnd', "")
        timeStart = request.args.get('datetimeStart', "")
        if(timeEnd != ""): params["datetimeEnd"] = timeEnd
        if(timeStart != ""): params["datetimeStart"] = timeStart
            
        #调用
        lstReturn = quoteSource.queryHistory(checkTime = False, params = params)

        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        if(lstReturn != None):
            datas = []
            for x in lstReturn:
                datas.append(x.toDict_Simple())
            pMsg['datas'] = datas
            pMsg['result'] = True
        #使用jsonify来讲定义好的数据转换成json格式,并且返回给前端
        return jsonify(pMsg) 
示例#9
0
def _Depth_str(strSeg = "  ", nSeg = 1):
    nDeepth = gol._Get_Setting('Debug_Depth') 
    strDepth = ""
    while(nDeepth > 0):
        strDepth += strSeg * nSeg + " "
        nDeepth -= 1
    return strDepth.strip() 
示例#10
0
    def __init__(self, pData, interval = 1):
        self.name = pData.name
        self.interval_M = interval                      #分钟级间隔
        self.datas = {}                                 #原始数据 
        self.datasS = []                                #统计数据集--天
        self.datasS_M = None                            #统计数据对象--分钟级
        self.data = pData                               #当前数据对象

        self.setting = myQuote_Setting._Find(pData.name, pData.idTag)        #配置项,以标识为准,避免名称不统一
        self.autoSave = True 
        self.stoped = False 
        self.tagTime = datetime.datetime.now()
        self.manageTrades = gol._Get_Setting('manageBills_Stock', None)     #使用交易管理器
        gol._Set_Value('datas_Stics_D_' + pData.id, self.datasS)            #全局统计信息


        #保存基础数据
        strDir, strName = myIO.getPath_ByFile(__file__)
        Dir_Base = os.path.abspath(os.path.join(strDir, ".."))   

        self.dir = Dir_Base + "/Data/" + self.name + "/"
        self.fileName = myData_Trans.Tran_ToDatetime_str(pData.getTime(), "%Y-%m-%d")
        myIO.mkdir(self.dir) 
        if(self.loadData()):                            #加载已存数据
            self.setData(pData)
示例#11
0
    def get(self): 
        # We run the proof of work algorithm to get the next proof...
        blockchain = gol._Get_Setting("zxcBlockChain", None)
        last_block = blockchain.last_block
        last_proof = last_block.proof
        proof = blockchain.proof_of_work(last_proof)

        # We must receive a reward for finding the proof.
        # The sender is "0" to signify that this node has mined a new coin.
        blockchain.new_transaction(
            sender="0",
            recipient=node_identifier,
            amount=1,
        )

        # Forge the new Block by adding it to the chain
        previous_hash = blockchain.hash(last_block)
        block = blockchain.new_block(proof, previous_hash)

        response = {
            'message': "New Block Forged",
            'index': block['index'],
            'transactions': block['transactions'],
            'proof': block['proof'],
            'previous_hash': block['previous_hash'],
        }
        return jsonify(response), 200
示例#12
0
    def get(self):
        usrID = request.args.get('usrID', "")
        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))

        #初始返回组
        lstExtypes = []
        lstCode_id = []
        lstCode_Name = []
        lstCode_NameEN = []

        #查询及组装
        pSets = gol._Get_Value('setsQuote', None)
        if (pSets != None and usrID != ""):
            lstStock = pSets._Find_Sets(usrID)
            for x in lstStock:
                lstExtypes.append(x.extype)
                lstCode_id.append(x.code_id)
                lstCode_Name.append(x.code_name)
                lstCode_NameEN.append(x.code_name_En)

        jsonStocks = {}
        jsonStocks["extypes"] = lstExtypes
        jsonStocks["code_ids"] = lstCode_id
        jsonStocks["code_names"] = lstCode_Name
        jsonStocks["code_namesEN"] = lstCode_NameEN

        pMsg['result'] = len(lstExtypes) > 0
        pMsg['text'] = jsonStocks
        return pMsg
示例#13
0
def _initMsg_Swap(useMQ=False):
    if (gol._Get_Setting('dirMsgsSwaps', None) == None):
        gol._Set_Setting(
            'dirMsgsSwaps',
            "D:/myCode/zxcProj/src/Zxc.Python/zxcPy.Weixin/Data/Swaps"
        )  #实例 消息缓存

    gol._Set_Setting('bufferMsgs', myMsgs("zxc", "zxc", "", ""))  #实例 消息缓存
    gol._Set_Setting('manageMsgs', myManager_Msg())  #实例 消息管理器并初始消息api及消息队列
    if (useMQ):
        gol._Get_Setting('manageMsgs',
                         None)._Init_MQ(plat=myMsgPlat.robot,
                                        msgMQ_Sender=myMQ_Rabbit.myMQ_Rabbit(
                                            True, 'zxcMQ_robot'),
                                        msgUrl_API="")  #不使用api回调
        gol._Get_Setting('manageMsgs',
                         None)._Init_MQ(plat=myMsgPlat.wx,
                                        msgMQ_Sender=myMQ_Rabbit.myMQ_Rabbit(
                                            True, 'zxcMQ_wx'),
                                        msgUrl_API="",
                                        usrHelper='filehelper')  #不使用api回调
        gol._Get_Setting('manageMsgs',
                         None)._Init_MQ(plat=myMsgPlat.usrWin,
                                        msgMQ_Sender=myMQ_Rabbit.myMQ_Rabbit(
                                            True, 'zxcMQ_usrWin'),
                                        msgUrl_API="",
                                        isAuto_ack=True)  #不使用api回调
    else:
        dirMsgsSwaps = gol._Get_Setting('dirMsgsSwaps')
        pDataSwap_In = myData_Swap.myData_Swap_FileIO("msgWx",
                                                      dirMsgsSwaps +
                                                      "/SwapMsg",
                                                      stepSwaps=1,
                                                      delayedTime=0,
                                                      useAck=True,
                                                      nameSwap="zxcSwap_wx")
        gol._Get_Setting('manageMsgs')._Init_Swap(plat=myMsgPlat.wx,
                                                  msgSwap_Sender=pDataSwap_In,
                                                  isAuto_ack=True,
                                                  msgUrl_API="")
        pass
示例#14
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}
示例#15
0
    def get(self, msgInfo):
        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        if (msgInfo == ""): return pMsg

        #初始消息处理对象
        usrMMsg = gol._Get_Setting('manageMsgs', None)  #提取消息管理器
        if (usrMMsg == None): return pMsg

        #消息处理(应为异步处理)
        #msg = ast.literal_eval(msgInfo)
        pJson = myData_Json.Json_Object()
        pJson.Trans_FromStr(msgInfo)
        msg = pJson._dict_
        msg['msg'] = msg['msg'].replace("※r※", "\r").replace(
            "※n※", "\n").replace("※i※", '"').replace("※t※",
                                                     "\t").replace("※h※", "/")
        usrMMsg.OnHandleMsg(msg, 'wx', True)
        pMsg['result'] = True
        pMsg['text'] = "Swap Cached!"
        myDebug.Debug("API Msg-->>", str(msg))
        return pMsg
示例#16
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
示例#17
0
 def __init__(self): 
     self.usrTag = ""
     self.usrName = ""
     self.usrNameNick = ""
     self.usrReplys = myRoot_Usr.myRoot_Usrs("", "")   #消息用户集
     self.usrMMsg = gol._Get_Setting('manageMsgs')     #消息管理器
     self.usrMQ_Recv = None   #消息队列队形      
     self.isRunning = False   #是否运行中
     self._Init()             #按全局权限初始
     #self.wxDos = {}         #消息处理类
     #self.wxUser_Root = None #当前授权用户对象(避免频繁查找)
     myDebug.Print("消息处理工厂--已初始 (%s::%s--%s)" % (self.usrName, self.usrNameNick, self.usrTag))
示例#18
0
    def Init(self):
        self.usrName = gol._Get_Setting('usrName', "zxcRobot")  #归属用户
        self.usrNameNick = gol._Get_Setting('usrNameNick', "zxc机器人")  #归属用户昵称
        self.usrID = gol._Get_Setting('usrID', "zxcRobotID")  #归属用户ID

        #用户集
        if (self.usrInfos == None):
            self.usrInfos = myRoot_Usr.myRoot_Usrs("", "")
            self.usrInfos_sys = myRoot_Usr.myRoot_Usrs(self.usrID,
                                                       self.usrName,
                                                       self.usrNameNick)
            gol._Set_Value('rootRobot_usrInfos', self.usrInfos)
            gol._Set_Value('rootRobot_usrInfos_sys', self.usrInfos_sys)
        self.usrInfos.usrName = self.usrName
        self.usrInfos.usrID = self.usrID

        #群组集
        if (self.usrGroups == None):
            self.usrGroups = myRoot_GroupInfo.myRoot_GroupsInfo("", "")
            self.usrGroups_sys = myRoot_GroupInfo.myRoot_GroupsInfo(
                self.usrID, self.usrName)
            gol._Set_Value('rootRobot_usrGroups', self.usrGroups)
            gol._Set_Value('rootRobot_usrGroups_sys', self.usrGroups_sys)
        self.usrGroups.usrName = self.usrName
        self.usrGroups.usrID = self.usrID

        #功能集
        if (self.rootPrjs == None):
            self.rootPrjs = myRoot_Prj.myRoots_Prj(self.usrName, self.usrID)
        else:
            self.rootPrjs.usrName = self.usrName
            self.rootPrjs.usrID = self.usrID

        #平台集
        if (self.usrPlats == None):
            self.usrPlats = myRoot_Plat.myRoot_Plats(self.usrName, self.usrID)
        else:
            self.usrPlats.usrName = self.usrName
            self.usrPlats.usrID = self.usrID
        self.Init_Plats()  #初始平台
示例#19
0
    def __init__(self, recv=False):
        self.usrMMsg = gol._Get_Setting('manageMsgs')  #消息管理对象
        self.manager = {}
        self.managerTemp = []
        self.mqRecv = None
        self.isRuning = True
        self.init_MQ(recv)

        #初始根目录信息
        strDir, strName = myIO.getPath_ByFile(__file__)
        self.baseDir = os.path.abspath(os.path.join(strDir, ".."))
        self.imgDir = self.baseDir + "/Data/Images/imgQuote/"
        self.setWinForm = gol._Get_Value('zxcWinForm_Control', None)
示例#20
0
 def __init__(self, tag, bUseMQ = True, robot_API = "http://127.0.0.1:8668/zxcAPI/robot"):
     self.usrTag = tag
     self.usrID = "zxcID"
     self.usrName = "墨紫"
     self.nickName = ""
     self.robotAPI = myWeb_urlLib.myWeb(robot_API)   #WebAPI
     self.routeReply = "reply/"                      #消息处理接口路由名
     self.usrMMsg = gol._Get_Setting('manageMsgs')   #消息管理对象
     self.useMQ = bUseMQ
     
     #初始本地路径
     strDir, strName = myIO.getPath_ByFile(__file__)
     self.dirBase = os.path.abspath(os.path.join(strDir, ".."))   
示例#21
0
def Print(*args, type = "*"):
    if(gol._Get_Setting('CanPrint')):
        strText = ""
        for x in args:
            strText += str(x)
    
        strDepth = _Depth_str()
        if(strDepth == ""):
            #print(type + "->>", strText) 
            print("", type, strText) 
        else:
            #print(type + "->>", strDepth, strText) 
            print("", type, strDepth, strText) 
示例#22
0
    def __init__(self, usrID="", usrName=""):
        super().__init__(usrID, usrName)
        self.doTitle = "Robot_Msg"  #说明
        self.prjName = "消息处理"  #功能名
        self.doCmd = "@@zxcRobot_Msg"  #启动命令
        self.isBackUse = True  #后台运行
        self.maxTime = -1  #永久有效

        #初始全局操作对象
        #self.webQuote = myWeb_urlLib.myWeb("http://127.0.0.1:8669/zxcAPI/robot", "", False)
        self.myRobot = myRobot_Robot.myRobot_Robot()
        self.bufMsgs = gol._Get_Setting('bufferMsgs')  #消息缓存
        self.myRobot.isRunning = True
示例#23
0
    def __init__(self, usrID="", usrName=""):
        super().__init__(usrID, usrName)
        self.doTitle = "Robot_Log"  #说明
        self.prjName = "消息日志"  #功能名
        self.doCmd = "@@zxcRobot_Log"  #启动命令
        self.isBackUse = True  #后台运行
        self.maxTime = -1  #永久有效
        self.msgLogs = gol._Get_Setting('manageMsgs')  #全局消息日志管理器

        #初始根目录信息
        strDir, strName = myIO.getPath_ByFile(__file__)
        self.Dir_Base = os.path.abspath(os.path.join(strDir, "../.."))
        self.Dir_LogMsg = self.Dir_Base + "/Log/Msgs/"
        self.usrMMsg.Init_LogDir(self.Dir_LogMsg)  #初始日志路径
示例#24
0
    def get(self):
        # queryIDs=sh000001,sh601939
        global quoteSource
        ids = request.args.get('queryIDs', "")
        lstReturn = quoteSource.query(params = {'queryIDs' : ids})

        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        if(lstReturn != None):
            datas = []
            for x in lstReturn:
                datas.append(x.toDict())
            pMsg['datas'] = datas
            pMsg['result'] = True
        #使用jsonify来讲定义好的数据转换成json格式,并且返回给前端
        return jsonify(pMsg) 
示例#25
0
def Debug_byTag(tag, msg = "", bRecord = False, bTitle = True):
    nTime = time.time()
    ms_Deepth = gol._Get_Setting('Debug_Depth') 
    if(bRecord):        #记录信息
        ms_Msgs[tag] = nTime
        Debug(tag, "", msg, "\n              ", "--Start at", datetime.datetime.fromtimestamp(nTime).strftime('%H:%M:%S.%f')) 
        ms_Deepth += 1
        gol._Set_Setting('Debug_Depth', ms_Deepth) 
         
    elif(ms_Msgs.__contains__(tag)):
        nInterval = nTime - ms_Msgs[tag]
        ms_Deepth -= 1
        gol._Set_Setting('Debug_Depth', ms_Deepth) 
        if(bTitle):
            Debug(tag, "", msg, "\n              ", "--End at", datetime.datetime.fromtimestamp(nTime).strftime('%H:%M:%S.%f'), "\n      ", "--耗时:", round(nInterval, 3), "秒")  
        return nInterval
示例#26
0
    def __init__(self, useID):
        self.usrID = useID  #用户名
        self.usrTime = ""  #数据日期(月)
        self.remark = ""  #备注

        #初始数据路径
        strDir, strName = myIO.getPath_ByFile(__file__)
        self.Dir_Base = os.path.abspath(os.path.join(strDir, "../../.."))
        self.Dir_DataDB = self.Dir_Base + "/Data/DB_Trade/"

        #初始全局账单管理器
        from myGlobal import gol
        gol._Init()  #先必须在主模块初始化(只在Main模块需要一次即可)
        gol._Set_Setting('manageBills',
                         myManager_Bill.myManager_Bill(
                             self.Dir_DataDB))  #实例 账单管理器
        self.billManager = gol._Get_Setting('manageBills', None)
示例#27
0
    def get(self, usrName, usrID, PlatName):
        pMsg = copy.deepcopy(gol._Get_Setting('Return_strFormat', {}))
        if (PlatName == ""): return pMsg

        #提取平台集
        pRoot = gol._Get_Value('rootRobot')
        pPlats = pRoot.usrPlats
        pPlat = pPlats.Find(PlatName)
        if (pPlat == None):
            pPlat = pPlats.Regist(usrName, usrID, PlatName)

        pMsg['result'] = True
        pMsg['toke'] = pPlat.usrToken

        #初始消息处理对象
        init_Reply()._Init()
        return pMsg
示例#28
0
    def __init__(self, usrID="", usrName=""):
        super().__init__(usrID, usrName)
        self.doTitle = "账单管家"  #说明
        self.prjName = "账单管家"  #功能名
        self.doCmd = "@@BillManager"  #启动命令
        self.isSingleUse = False  #是否为单例使用(非单例时每个用户专属)
        self.msg['FromUserName'] = self.usrName

        self.manageBills = gol._Get_Setting('manageBills', None)  #使用全局账单管理器
        self.billTypes = myManager_Bill.myBileType  #账单类型集
        self.billTradeTypes = myManager_Bill.myTradeType  #交易品类型集
        self.bills = myManager_Bill.myObj_Bills("")  #账单对象-当前
        self.billUsr = ""  #账单归属人-当前
        self.billType = ""  #账单类型-当前
        self.billTradeParty = ""  #账单交易人-当前
        self.billTradeTarget = ""  #账单交易物-当前
        self.billTradeType = ""  #账单交易物品类-当前
        self.billTradeTargetType = ""  #账单交易物品子类-当前
示例#29
0
    def usrInfoQuery():
        name = request.args.get('name', "")
        phone = request.args.get('phone', "")
        pUsers = gol._Get_Setting('sysUsers', None)  #实例 用户对象集
        users = pUsers._Find_ByRealInfo(name, phone)

        jsonUsers = myData_Json.Json_Object()
        lstUsers = []
        lstPhones = []
        lstAddress = []
        for x in users:
            lstUsers.append(x.usrName_Full)
            lstPhones = lstPhones + x.usrPhones
            lstAddress = lstAddress + x.usrAddresss
        jsonUsers["usrName_Fulls"] = lstUsers
        jsonUsers["usrPhones"] = lstPhones
        jsonUsers["usrAddresss"] = lstAddress
        return jsonUsers.ToString()
示例#30
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