Beispiel #1
0
def update_user_level(server_id, user_id, level):
    level = int(level)
    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        info = cursor.fetchone(
            "select exp from system_user_level where user_level = %s" %
            (level + 1))
        if info:
            exp = info["exp"] - 10
        else:
            exp = 10000 * 10000

        server = server_business.get_server(server_id)
        host = server.server_host

        path = "/gameApi/updateUserLevel.do"
        logging.debug("host:[%s], path[%s]" % (host, path))
        data = {"userId": user_id, "level": level, "exp": exp}

        post = Post(data, host, path, port=8088)
        content = post.submit(result_keyword=None,
                              get_content=True,
                              debug=True)
        try:
            info = json.loads(content)
            return info.get("rc", 3000) == 1000
        except:
            logging.debug("bad json format:[%s]" % content)
    finally:
        cursor.close()
Beispiel #2
0
def update_user_level(server_id, user_id, level):
    level = int(level)
    db_config = server_business.get_server_db_connect(server_id=server_id)
    connect = get_connection(db_config)
    cursor = connect.cursor()
    try:
        info = cursor.fetchone("select exp from system_user_level where user_level = %s" % (level + 1))
        if info:
            exp = info["exp"] - 10
        else:
            exp = 10000 * 10000
        
        server = server_business.get_server(server_id)
        host = server.server_host
    
        path = "/gameApi/updateUserLevel.do"
        logging.debug("host:[%s], path[%s]" % (host, path))
        data = {"userId": user_id, "level": level, "exp": exp}
    
        post = Post(data, host, path, port=8088)
        content = post.submit(result_keyword=None, get_content=True, debug=True)
        try:
            info = json.loads(content)
            return info.get("rc", 3000) == 1000
        except:
            logging.debug("bad json format:[%s]" % content)
    finally:
        cursor.close()
def data_sync(server_id, sync_type=1, table=None, sqls=[]):
    """数据同步"
    @param sync_type: 同步类型1:修改 ;2:新增 ;3:删除;4:全表同步 
    @param table:同步的表
    @param sqls:同步的sql
    """
    server = Server.load(server_id=server_id)
    host = server.server_host

    path = "/gameApi/dataSync.do"
    logging.debug("host:[%s], path[%s]" % (host, path))
    data = {"syncType": sync_type, "table": table, "sqls": json.dumps(sqls)}

    post = Post(data, host, path, port=8088)
    content = post.submit(result_keyword=None, get_content=True, debug=True)
    try:
        info = json.loads(content)
        return info.get("rc", 3000) == 1000
    except:
        logging.debug("bad json format:[%s]" % content)
        return False
Beispiel #4
0
def data_sync(server_id, sync_type=1, table=None, sqls=[]):
    """数据同步"
    @param sync_type: 同步类型1:修改 ;2:新增 ;3:删除;4:全表同步 
    @param table:同步的表
    @param sqls:同步的sql
    """
    server = Server.load(server_id=server_id)
    host = server.server_host

    path = "/gameApi/dataSync.do"
    logging.debug("host:[%s], path[%s]" % (host, path))
    data = {"syncType": sync_type, "table": table, "sqls": json.dumps(sqls)}

    post = Post(data, host, path, port=8088)
    content = post.submit(result_keyword=None, get_content=True, debug=True)
    try:
        info = json.loads(content)
        return info.get("rc", 3000) == 1000
    except:
        logging.debug("bad json format:[%s]" % content)
        return False