示例#1
0
 def run(self):
     
     f_sql_1 = open("/data/game_fix.sql", "wb")
     f_sql_2 = open("/data/web_fix.sql", "wb")
     try:
         servers, _ = server_business.get_server_list(1, 30, 2)
         for server in servers:
             db_config = server_util.str_to_dbconfig(server.db_connect)
             conn = get_connection(db_config)
             cursor = conn.cursor()
             try:
                 infos = cursor.fetchall("select partner_user_id, partner_id from user_mapper where partner_id in (1020, 1010) ")
                 for info in infos:
                     partner_user_id_old = info["partner_user_id"]
                     partner_id = info["partner_id"]
                     partner_user_id_new = self.get_partner_user_id(partner_user_id_old)
                     if partner_user_id_new:
                         self.log("old[%s], new[%s]" % (partner_user_id_old, partner_user_id_new))
                         f_sql_1.write("update user_mapper set partner_user_id='%s' where partner_user_id='%s' and partner_id=%s limit 1;\n" % (partner_user_id_new, partner_user_id_old, partner_id))
                         f_sql_1.write("update payment_log set partner_user_id='%s' where partner_user_id='%s' and partner_id=%s limit 1;\n" % (partner_user_id_new, partner_user_id_old, partner_id))
                         f_sql_2.write("update payment_order set partner_user_id='%s' where partner_user_id='%s' and partner_id=%s limit 1;\n" % (partner_user_id_new, partner_user_id_old, partner_id))
                         
             finally:
                 cursor.close()
     finally:
         f_sql_1.close()
         f_sql_2.close()
示例#2
0
 def run(self):
     
     
     qa_db_config = server_business.get_server_db_connect(server_id="t2")
     qa_conn = get_connection(qa_db_config)
     qa_cursor = qa_conn.cursor()
     infos = qa_cursor.fetchall("show tables")
     tables = []
     for info in infos:
         table = info["Tables_in_ldsg_t2"]
         tables.append(table)
     
     try:
         servers, _ = server_business.get_server_list(1, 30, 2)
         for server in servers:
             db_config = server_util.str_to_dbconfig(server.db_connect)
             conn = get_connection(db_config)
             cursor = conn.cursor()
             try:
                 for table in tables:
                     try:
                         info = cursor.fetchone("select 1 from %s limit 1" % table)
                     except:
                         print "error:server:%s,table:%s" % (server.server_id, table)
                        
             finally:
                 cursor.close()
     finally:
         pass
示例#3
0
def get_server_online_list(server_zone):
    server_list, _ = server_business.get_server_list(0, 10000, server_zone)
    server_online_infos = []
    for server in server_list:
        online = get_server_online(server.redis_connect)
        logging.debug("server:%s, online:%s" % (server.server_id, online))
        server_online_infos.append({"server_id": server.server_id, "count": online})
    return server_online_infos
示例#4
0
def get_server_online_list(server_zone):
    server_list, _ = server_business.get_server_list(0, 10000, server_zone)
    server_online_infos = []
    for server in server_list:
        online = get_server_online(server.redis_connect)
        logging.debug("server:%s, online:%s" % (server.server_id, online))
        server_online_infos.append({
            "server_id": server.server_id,
            "count": online
        })
    return server_online_infos
示例#5
0
 def run(self):
     
     f = open("/data/update.sql", "wb")
     try:
         servers, _ = server_business.get_server_list(1, 30, 2)
         for server in servers:
             db_config = server_util.str_to_dbconfig(server.db_connect)
             conn = get_connection(db_config)
             cursor = conn.cursor()
             try:
                 sql ="""select * from user_mapper where user_id in (select user_id from user where level <=5 and user_id in (select user_id from user_mapper where partner_user_id in (select partner_user_id from (select count(1) as total, partner_user_id from user_mapper where partner_id = 1010 group by partner_user_id)t where total > 1))) ;"""
                 infos = cursor.fetchall(sql)
                 for info in infos:
                     user_mapper_id = info["user_mapper_id"]
                     print user_mapper_id
                     f.write("update user_mapper set partner_user_id = CONCAT(user_id, '_',  partner_user_id) where user_mapper_id = %s limit 1;\n" % user_mapper_id)
             finally:
                 cursor.close()
     finally:
         f.close()
         pass
示例#6
0
    def run(self):

        f = open("/data/update.sql", "wb")
        try:
            servers, _ = server_business.get_server_list(1, 30, 2)
            for server in servers:
                db_config = server_util.str_to_dbconfig(server.db_connect)
                conn = get_connection(db_config)
                cursor = conn.cursor()
                try:
                    sql = """select * from user_mapper where user_id in (select user_id from user where level <=5 and user_id in (select user_id from user_mapper where partner_user_id in (select partner_user_id from (select count(1) as total, partner_user_id from user_mapper where partner_id = 1010 group by partner_user_id)t where total > 1))) ;"""
                    infos = cursor.fetchall(sql)
                    for info in infos:
                        user_mapper_id = info["user_mapper_id"]
                        print user_mapper_id
                        f.write(
                            "update user_mapper set partner_user_id = CONCAT(user_id, '_',  partner_user_id) where user_mapper_id = %s limit 1;\n"
                            % user_mapper_id)
                finally:
                    cursor.close()
        finally:
            f.close()
            pass
示例#7
0
def server_list(request):
    page = int(request.REQUEST.get("page", 1))
    pagesize = int(request.REQUEST.get("pagesize", 20))
    server_zone = int(request.REQUEST.get("server_zone", 2))
    infos, total = server_business.get_server_list(page, pagesize, server_zone)
    return render_to_response(request, "admin/server_list.html", locals())