Example #1
0
    def do_test(self, data):
        for i in range(2017070,2017094):
            data = {}
            data["outNO"] = str(i)
            data["outdate"] = str(i)

            pymysqlHandle = PymysqlHandle()
            outresult = pymysqlHandle.getFCDatabyOutData(data)
            outdata = outresult['result']
            outStr = str(outdata['out_bai'])+str(outdata['out_shi'])+str(outdata['out_ge'])
            result = self.do_getFrequencyData(data)
            reply = ""
            if result["infoCode"] == 0:
                enddata = result['result']['endData'];
                endData  = {}
                endData["outdate"] = str(outdata['outdate'])
                endData["outNum"] = outStr
                endData["Balance"] = enddata[outStr]
                reply = PythonString.jsonUnPase(endData)
                length = len(reply)
                self.connection.send('%c%c%s' % (0x81, length, reply))
            else:
                reply  = result['result']+'\n'
                length = len(reply)
                self.connection.send('%c%c%s' % (0x81, length, reply))
                break;
Example #2
0
    def do_getAdminList(self, data, userID):

        sqlhandle = PymysqlHandle()
        result = sqlhandle.getAdminList(data, userID)
        if result == None:
            raise CustomError(-10001)
        else:
            return result
Example #3
0
 def do_getAdminInfo(self, data, userID):
     if ("userID" not in data.keys()):
         raise CustomError(-20005, "userID")
     userID = data['userID']
     pymysqlHandle = PymysqlHandle()
     result = pymysqlHandle.selectUserInfo(userID)
     if result == None:
         raise CustomError(-10001)
     return result
Example #4
0
def reloadData(connection):
    downLoad = DownLoadFile()

    savepath = downLoad.downLoadFile("http://www.17500.cn/getData/3d.TXT",
                                     "Data/3d.cvs")
    LogHandle.logs(0, '下载最新FC3D数据文件到本地完成', 'SYSROOT', 0, 'getData', connection)

    pymysqlHandle = PymysqlHandle()
    pymysqlHandle.loadFC3DDataByText(savepath)
    LogHandle.logs(0, '加载FC3D数据文件到sql完成', 'SYSROOT', 0, 'getData', connection)

    fc3DOmit = FC3DOmit()
    fc3DOmit.reloadOmitData()
    LogHandle.logs(0, '录入FC3D数据遗漏数据完成', 'SYSROOT', 0, 'getData', connection)

    fc = FC3DProbability()
    fc.loadProbabilityData(5)
    LogHandle.logs(0, '录入FC3D频率表5数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(10)
    LogHandle.logs(0, '录入FC3D频率表10数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(15)
    LogHandle.logs(0, '录入FC3D频率表15数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(20)
    LogHandle.logs(0, '录入FC3D频率表20数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(25)
    LogHandle.logs(0, '录入FC3D频率表25数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(30)
    LogHandle.logs(0, '录入FC3D频率表30数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(50)
    LogHandle.logs(0, '录入FC3D频率表50数据完成', 'SYSROOT', 0, 'getData', connection)
    fc.loadProbabilityData(100)
    LogHandle.logs(0, '录入FC3D频率表100数据完成', 'SYSROOT', 0, 'getData', connection)

    zuf = FC3DZUPribability()
    zuf.loadProbabilityData(5)
    LogHandle.logs(0, '录入组选FC3D频率表5数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(10)
    LogHandle.logs(0, '录入组选FC3D频率表10数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(15)
    LogHandle.logs(0, '录入组选FC3D频率表15数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(20)
    LogHandle.logs(0, '录入组选FC3D频率表20数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(25)
    LogHandle.logs(0, '录入组选FC3D频率表25数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(30)
    LogHandle.logs(0, '录入组选FC3D频率表30数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(50)
    LogHandle.logs(0, '录入组选FC3D频率表50数据完成', 'SYSROOT', 0, 'getData', connection)
    zuf.loadProbabilityData(100)
    LogHandle.logs(0, '录入组选FC3D频率表100数据完成', 'SYSROOT', 0, 'getData',
                   connection)
Example #5
0
    def do_register(self, data, userID):

        if ("userName" not in data.keys()):
            raise CustomError(-20005, "userName")
        if ("passWord" not in data.keys()):
            raise CustomError(-20005, "passWord")
        if ("phone" not in data.keys()):
            raise CustomError(-20005, "phone")

        userName = data['userName']
        telNO = data['phone']
        passWord = data['passWord']
        pymysqlHandle = PymysqlHandle()
        sqlpass = bcrypt.hashpw(passWord.encode('utf-8'), bcrypt.gensalt(8))
        pymysqlHandle.insetUserInfo(userName, telNO, sqlpass)
Example #6
0
    def do_addParametervalue(self, data):
          
        data_Dic = {
                    "parameterName":data['parameterName'],
                    "parameterDescribe":data['parameterDescribe'],
                    "parameterEndTime":"--",
                    "parameterBeginVersions":data['parameterBeginVersions'],
                    "parameterEndVersions":data['parameterEndVersions'],
                    "parameterType":data['parameterType'],
                    "parameterFatherName":data['parameterFatherName'],
                    "parameterCanNil":data['parameterCanNil'],
                    "parameterTypeuse":data['parameterTypeuse']
                }

        pymysqlHandle = PymysqlHandle() 
        return pymysqlHandle.addParametervalue(data_Dic)
Example #7
0
    def do_login(self, data, userID):
        '''验证入参'''
        if ("userName" not in data.keys()):
            raise CustomError(-20005, "userName")
        if ("passWord" not in data.keys()):
            raise CustomError(-20005, "passWord")

        passWord = data['passWord'].encode('utf-8')
        userName = data['userName']
        '''获取会员信息'''
        pymysqlHandle = PymysqlHandle()
        result = pymysqlHandle.selectUserInfoWithUserName(userName)
        if result == None:
            raise CustomError(-10001)

        sqlpass = result["passWord"]
        '''验证会员密码'''
        if not bcrypt.checkpw(passWord, sqlpass.encode('utf-8')):
            raise CustomError(-10002)
        '''查询section'''

        section = pymysqlHandle.getSection(result["userID"])

        if section != None:
            nowtime = time.time()
            if nowtime - section["createtime"] > 24 * 3600:
                pymysqlHandle.deleteSection(result["userID"])
                section = None
            else:
                if data["UUID"] != section["UUID"] and "UUID" in data.keys():
                    raise CustomError(-10001)

        if section == None:
            '''创建section'''
            salt = ''.join(
                random.sample(string.ascii_letters + string.digits, 32))
            uuid = "0000"
            if "UUID" in data.keys():
                uuid = data["UUID"]

            data = {
                'userID': result["userID"],
                'validityPeriod': 24,
                'createtime': time.time(),
                'session': salt,
                'UUID': uuid
            }
            pymysqlHandle.insterSection(data)
        del result["passWord"]
        result["section"] = salt
        return result
Example #8
0
    def do_getfileUrl(self,data,userID):

        url = "http://" + mod_config.getConfig("INTERFACE", "IP")+":"+mod_config.getConfig("INTERFACE", "PORT")
        '''
         downType:
         10001 :接口列表文件下载
        '''
        if(data["downType"] == 10001):

            savefile =  sys.path[0] + "/Data/InterFace.cvs"
            url = url + "/Data/InterFace.cvs"
            if  os.path.exists(savefile):
                os.remove(savefile)
            sqlhandle = PymysqlHandle()
            sqlhandle.createInterFacetxt(savefile)

            returnDic = {"infoCode":0}
            returnDic['result'] = {"url":url}
            return returnDic;


        else:
            returnDic = {"infoCode":-1}
Example #9
0
    def do_saveUpFile(self,data,userID):

        url = "http://" + mod_config.getConfig("INTERFACE", "IP")+":"+mod_config.getConfig("INTERFACE", "PORT")
        uptype = data["upType"]
        updata = data["file"][0]
        #上传接口数据
        if uptype == "1001":

            savefile =  sys.path[0] + "/Data/InterFace.txt"
            if  os.path.exists(savefile):
                os.remove(savefile)
            f = open(savefile, 'w')
            f.write(updata)
            f.close()

            sqlhandle = PymysqlHandle()
            sqlhandle.insterInterfaceData(savefile)
            returnDic = {"infoCode":0}
            returnDic['result'] = "scresss"
        #上传用户头像
        elif (uptype == "1002"):
            saveStr = "/Data/image/"+str(userID)+"head.png"
            savefile =  sys.path[0] + saveStr
            if  os.path.exists(savefile):
                os.remove(savefile)
            f = open(savefile, 'w')
            f.write(updata)
            f.close()

            url = url + saveStr
            headImage = {"headImage":url}
            sqlhandle = PymysqlHandle()
            sqlhandle.replaceUserInfo(headImage,userID)
            return headImage

        else:

            raise CustomError(-20006)

        return returnDic;
Example #10
0
    def do_getFC3DData(self, data):

        pymysqlHandle = PymysqlHandle()
        return pymysqlHandle.getFC3dData(data)
Example #11
0
    def do_replaceUserData(self, data, userID):

        sqlhandle = PymysqlHandle()

        sqlhandle.replaceUserInfo(data, userID)
Example #12
0
 def do_getOutputValueList(self, data): 
     interFaceName = data['interFaceName'].encode("utf-8")
     parameterTypeuse = "1002"
     pymysqlHandle = PymysqlHandle() 
     returnData = pymysqlHandle.getInterfaceParameterList(interFaceName, parameterTypeuse)
     return returnData 
Example #13
0
 def do_getInterFaceInfo(self, data):
    
     interFaceName = data['interFaceName']
     pymysqlHandle = PymysqlHandle() 
     returnData = pymysqlHandle.getInterFaceInfo(interFaceName)
     return returnData
Example #14
0
 def do_getInterFaceList(self, data):
     
     pymysqlHandle = PymysqlHandle() 
     returnData = pymysqlHandle.getInterfaceList(data)
     return returnData
Example #15
0
 def do_replaceInteface(self, data):
    
     pymysqlHandle = PymysqlHandle() 
     return pymysqlHandle.replaceIntefaceInfo(data)
Example #16
0
 def do_deleteInterFace(self,data):
     pymysqiHandle = PymysqlHandle()
     return pymysqiHandle.deleteInterFace(data)
Example #17
0
    def do_getOmitData(self, data):

        pymysqlHandle = PymysqlHandle()
        returnDic = pymysqlHandle.getOmitData(data)
        return returnDic
Example #18
0
    def do_getLastFCData(self, data):

        pymysqlHandle = PymysqlHandle()
        return pymysqlHandle.getLastFCData()
Example #19
0
    def do_removeAdmin(self, data, userID):
        sqlhandle = PymysqlHandle()

        sqlhandle.removeAdmin(data, userID)
Example #20
0
    def do_getFCDatabyOutData(self, data):

        pymysqlHandle = PymysqlHandle()
        return pymysqlHandle.getFCDatabyOutData(data)
Example #21
0
 def do_deleteParameter(self,data):
     pymysqlHandle = PymysqlHandle() 
     return pymysqlHandle.deleteParameter(data)
Example #22
0
    def do_wxLogin(self, data, userID):

        if "js_code" not in data.keys():
            raise CustomError(-20005, "js_code")
        if "nickName" not in data.keys():
            raise CustomError(-20005, "nickName")

        parm = {
            'appid': 'wx2d3eaf4304b22f25',
            'secret': '456d14753450c85718b290fa187bc369',
            'js_code': data["js_code"],
            'grant_type': 'authorization_code'
        }
        r = requests.post('https://api.weixin.qq.com/sns/jscode2session', parm)
        if r.status_code == 200:
            wxresult = PythonString.jsonPase(r.text)
            if 'errcode' not in wxresult.keys():

                pymysqlHandle = PymysqlHandle()
                result = pymysqlHandle.selectUserInfoBykey(
                    "wxOpenid", wxresult["openid"])
                data = {
                    'wxOpenid': wxresult['openid'],
                    'userName': data["nickName"],
                    'userID': result["userID"],
                    'headImage': data["headImg"]
                }
                if result == None:
                    pymysqlHandle.insetUser(data)
                    result = pymysqlHandle.selectUserInfoBykey(
                        "wxOpenid", wxresult["openid"])
                else:
                    pymysqlHandle.replaceUserInfo(data, result["userID"])

                userID = result["userID"]
                '''创建section'''

                section = pymysqlHandle.getSection(result["userID"])

                if section != None:
                    nowtime = time.time()
                    if nowtime - section["createtime"] > 24 * 3600:
                        pymysqlHandle.deleteSection(result["userID"])
                        section = None

                if section == None:
                    '''创建section'''
                    salt = ''.join(
                        random.sample(string.ascii_letters + string.digits,
                                      32))
                    createtime = time.time()
                    userID = result["userID"]

                    data = {
                        'userID': userID,
                        'validityPeriod': 24,
                        'createtime': createtime,
                        'session': salt,
                    }
                    pymysqlHandle.insterSection(data)
                    result["session"] = salt
                    return result

            else:
                raise CustomError(-30002)
        else:
            raise CustomError(-30001)
Example #23
0
 def do_addInterFace(self,data):
     pymysqlHandle = PymysqlHandle() 
     return pymysqlHandle.addInterFace(data["interFaceName"],data["interFaceNameStr"],data["interFacepath"])