def log_clear(request, server_id=0, log_type=0, clear_type=0): '''清除日志数据 ''' server_id = int(server_id) log_type = int(log_type) clear_type = int(clear_type) err_msg = '' if log_type > 0 : log_def = LogDefine.objects.get(id=log_type) try: if server_id > 0: try: conn = Server.get_conn(server_id) except: err_msg = '数据库链接出错!' else: conn = connection if clear_type == 0: sql = 'delete from log_%s' % log_def.key else: sql = 'drop table log_%s' % log_def.key cursor = conn.cursor() cursor.execute(sql) cursor.close() except Exception, e: print('clear data error:%s' % e)
def conn_switch(server_id): conn = None if 0 != server_id: conn = Server.get_conn(server_id) else: conn = connections['write'] return conn
def get_player_info(server_id, player_ids): """获取玩家信息(单个)""" conn = Server.get_conn(server_id) cur = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor) sql = '''select player_id,player_name,channel_id,user_type,link_key,login_num,mobile_key,last_time,create_time,status,other from player_%s p WHERE player_id in (%s)''' % (server_id, ','.join(player_ids)) cur.execute(sql) data_list = cur.fetchall() conn.close() return data_list
def __init__(self,sdate,edate,statistics,platform_keys=[],is_create_time=False): self.platforms = PlatForm.objects.filter(key__in=platform_keys) if platform_keys else PlatForm.objects.all() self.statistics = [ str(x) for x in statistics] self.statistics_models_list = Statistic.objects.filter(id__in=[int(x) for x in self.statistics]) self.sdate = sdate self.edate = edate self.center_con = Server.get_conn(0,connect_timeout=10) self.center_con.autocommit(False) self.is_create_time = is_create_time if self.is_create_time : #如果是按生成时间获取的 话,限制在开始时间内 self.sdate = datetime.datetime(self.sdate.year,self.sdate.month,self.sdate.day,0,0,0,0)
def log_data_delete(request, log_type): log_type = int(log_type) sdate = request.GET.get('sdate','') edate = request.GET.get('edate','') server_id = int(request.GET.get('server_id','0')) delete_date = '' size = 300 msg = '' if server_id > 0: delete_server = " AND `log_server` = %d " % server_id else: msg = '服务器ID不能为空!' if sdate != '' and edate != '': delete_date += "`log_time` >='%s' AND `log_time` <= '%s' " %(sdate, edate) print delete_date else: msg = '时间不能为空!' is_finish = 0 record = 0 if log_type > 0 and msg == '': print 'yes' log_def = LogDefine.objects.get(id=log_type) try: if server_id > 0: try: conn = Server.get_conn(server_id) except: msg = '数据库链接出错!' print msg else: conn = connection cursor = conn.cursor() record_sql = "SELECT COUNT(*) FROM `log_%s` WHERE %s %s"%(log_def.key, delete_date, delete_server) print record_sql cursor.execute(record_sql) record = int(cursor.fetchone()[0]) if record > 0: sql = 'DELETE FROM `log_%s` WHERE %s %s LIMIT %d' % (log_def.key, delete_date, delete_server,size) is_finish = cursor.execute(sql) else: is_finish = 0 cursor.close() except Exception, e: print('clear data error:%s' % e) msg = '%s'%e
def conference_send_mail(request, template="game/conferen_send_mail.html"): server_id = int(request.REQUEST.get("server_id", '') or 0) send_type = int(request.REQUEST.get('send_type', '') or 0) player_ids = request.REQUEST.get("player_ids", '') # 角色列表 格式 x1,x2, msg = request.REQUEST.get("msg", '') send_text = request.REQUEST.get('send_text', '') select_channel_ids = [] agent_channels_dict = get_agent_channels_dict(request) ###获取全部渠道和agent print "22222222222", request.admin.role.first( ).resource_ids, player_ids #############admin.id就是agent if player_ids: player_ids = json.loads(player_ids) if msg: _r = {'code': -1, 'msg': '', 'succ': [], 'fail': []} # 保存邮件内容 try: con = Server.get_conn(server_id) #######连接分服的数据库 cur = con.cursor() sql = "select channel_id from player_%s where player_id =%s" % ( server_id, player_ids[0]) ###分服获取当前渠道 cur.execute(sql) res = cur.fetchall() cha_id = int(res[0][0]) if res[0][0] else 0 msg = json.loads(msg) model = Mail() # "ty":类型(0 个人 2 全服 3 联远商ID) model.title = msg.get("t", "") model.content = msg.get("m", "") if msg["rw"]: model.bonus_content = json.dumps(msg["rw"][0]["act"]) model.type = msg["ty"] model.server_ids = str(server_id) model.channel_id = cha_id # model.player_id = json.dumps(player_ids) if player_ids else "" model.player_id = player_ids if player_ids else '' model.Applicant = str(request.admin.id) model.create_time = datetime.datetime.now() model.status = 0 model.save(using='write') _r['code'] = 0 err_msg = "成功保存" cur.close() con.commit() con.close() except Exception, e: traceback.print_exc() err_msg = trace_msg() _r['msg'] = err_msg return HttpResponse(json.dumps(_r))
def log_syncdb_do(request,server_id=0): '''同步数据库 ''' server_id = server_id or int(request.REQUEST.get('sid', '0')) is_ajax = request.is_ajax() or request.REQUEST.get('ajax','') err_msg = '' _r = {"code":1,"content":[]} sync_status = {} try: if server_id: is_center = False the_server = Server.objects.get(id=server_id) the_server.create_base_table() #创建数据库,创建player表,创建log基表 conn = the_server.mysql_conn() else: is_center = True conn = Server.get_conn(0) table_status = {"tol_num":0, "sync_num":0, "already_num":0 } index_status = copy.deepcopy(table_status) status = LogDefine.Status.CENTER if is_center else LogDefine.Status.NORMAL cur = conn.cursor() log_defs = LogDefine.objects.filter(status=status) for log_def in log_defs: table_status["tol_num"] += 1 create_tabls_sql = log_def.get_create_table_sql() try: cur.execute(create_tabls_sql) #同步表 table_status["sync_num"] += 1 except MySQLdb.Warning,e: table_status["already_num"] += 1 for create_index_sql in log_def.get_create_index_sqls() : #同步索引 index_status["tol_num"] += 1 #print create_index_sql try: cur.execute(create_index_sql) index_status["sync_num"] += 1 except MySQLdb.OperationalError,e: index_status["already_num"] += 1 except: err_msg = trace_msg() print trace_msg()
def get_player_list(self, server_id, count): # 获取分服玩家列表信息 if not server_id or not count: return try: conn = Server.get_conn(server_id) sql = ''' select last_ip,c,link_key from(select last_ip,count(0) c ,link_key from player_%d group by last_ip) a where c >= %d and last_ip != "" ''' % (server_id, count) cursor = conn.cursor() cursor.execute(sql) result = cursor.fetchall() print result return result except BaseException as e: print "%s 链接数据库时发生错误!%s" % (server_id, e) return []
def log_syncdb_data(request, server_id=0): '''同步创建表 ''' err_msg = '' server_id = int(server_id) if 0 == server_id: server_id = int(request.GET.get('server_id', 0)) if 0 == server_id: server_id = int(request.POST.get('server_id', 0)) if server_id > 0: try: conn = Server.get_conn(server_id) except: err_msg = '数据库链接出错!' else: conn = connection if err_msg != '': parg = {} parg["err_msg"] = err_msg return render_to_response('feedback.html', parg) cursor = conn.cursor() is_reload = True page_size = 50 try: #sql = 'select id,log_result from log_create_role where log_channel=0 limit %d'%page_size sql = 'select id,log_result from log_create_role where log_channel=0 and log_result>0 limit %d' % page_size print(sql) cursor.execute(sql) list_record = cursor.fetchall() if len(list_record) < 10: is_reload = False for item in list_record: the_user = User.objects.get(id=item[1]) if the_user.channel_key != '': the_channel = Channel.objects.get(channel_key=the_user.channel_key) sql = 'update log_create_role set log_channel=%d where id=%d' % (the_channel.id, int(item[0])) print(sql) cursor.execute(sql) except Exception, e: print('syncdb data has error', e)
def handle(self, *args, **kwargs): while True: keep_connections() base_sql = self.get_base_sql() servers = Server.objects.all() base_info = self.get_base_info() for s in servers: try: game_data = {} if not s.json_data: conn = Server.get_conn(s.id) for logName,logSql in base_sql.iteritems(): print '-'*40 print s.id,logSql print '-'*40 cursor = conn.cursor() cursor.execute(logSql) result = cursor.fetchone() game_data[logName] = float(result[0]) if result[0] else "" cursor.close() s.game_data = json.dumps(game_data) s.save(using="write") else: master_id = json.loads('{%s}' % s.json_data)["master_server_id"] server = Server.objects.get(id=master_id) game_data = json.loads(server.game_data) for field,value in base_info.iteritems(): if game_data.has_key(field): if s.id not in game_data[field]: _ = game_data[field] _.append(unicode(s.id)) game_data[field] = _ else: game_data[field] = [str(s.id)] server.game_data = json.dumps(game_data) server.save(using="write") except BaseException as e: print s.id,e s.game_data = json.dumps({"top_power":"","avg_power":"","ten_power":"","avg_level":"","sub_server":[]}) s.save(using="write") continue print u"现在时间:",datetime.datetime.now() time.sleep(6400)
def check_player_channel(request): '''检查用户拥有的渠道是否和发送的玩家一致''' cha_list = list(request.admin.role.first().resource_ids.get('channel', '')) # 用户拥有的渠道 player = request.REQUEST.get("player", '') player_ids = eval(player) print player_ids if isinstance(player_ids, int): player_ids = [player_ids] try: vv = [] for i in player_ids: server_id = i >> 20 print i, server_id sql = "select channel_id from player_%s where player_id =%s" % (server_id, i) #############分服获取当前渠道 con = Server.get_conn(server_id) #######连接分服的数据库 cur = con.cursor() cur.execute(sql) res = cur.fetchall() print 'oooooooooooooo', cha_list, player, res[0][0], server_id, vv.__len__() if res[0][0] and int(res[0][0]) in cha_list: if vv.__len__() == 0: vv.append(int(res[0][0])) else: if int(res[0][0]) == vv[0]: pass else: return HttpResponse(i) else: return HttpResponse(i) cur.close() con.close() return HttpResponse(0) except Exception, e: print e return HttpResponse(33)
def create_center_platform_statistic_table(cls): #保存结果表 platfrom_result_table_sql = '''CREATE TABLE IF NOT EXISTS `%s` ( `id` int(11) NOT NULL AUTO_INCREMENT, `log_type` int(11) NOT NULL, `log_user` int(11) DEFAULT NULL, `log_name` varchar(100) DEFAULT NULL, `log_server` int(11) DEFAULT NULL, `log_channel` int(11) DEFAULT NULL, `log_data` int(11) DEFAULT NULL, `log_result` int(11) DEFAULT NULL, `log_level` int(11) DEFAULT NULL, `log_time` datetime NOT NULL, `log_previous` varchar(200) DEFAULT NULL, `log_now` varchar(200) DEFAULT NULL, `log_tag` int(11) DEFAULT NULL, `f1` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`,`log_time`), KEY `log_platform_result_log_type` (`log_type`), KEY `log_platform_result_log_time` (`log_time`), KEY `log_platform_result_log_server` (`log_server`), KEY `log_platform_result_log_channel` (`log_channel`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY RANGE (year(log_time)) ( PARTITION p201x VALUES LESS THAN (2010), PARTITION p2010 VALUES LESS THAN (2011), PARTITION p2011 VALUES LESS THAN (2012), PARTITION p2012 VALUES LESS THAN (2013), PARTITION p2013 VALUES LESS THAN (2014), PARTITION p2014 VALUES LESS THAN (2015), PARTITION p2015 VALUES LESS THAN (2016), PARTITION p2016 VALUES LESS THAN (2017), PARTITION p2017 VALUES LESS THAN (2018), PARTITION p2018 VALUES LESS THAN (2019), PARTITION p2019 VALUES LESS THAN (2020), PARTITION p202x VALUES LESS THAN (MAXVALUE) ) ''' % cls.result_table_name #保存结果临时表 platfrom_result_tmp_table_sql = ''' CREATE TABLE IF NOT EXISTS `%s` ( `log_type` int(11) NOT NULL, `log_user` int(11) DEFAULT NULL, `log_name` varchar(100) DEFAULT NULL, `log_server` int(11) DEFAULT NULL, `log_channel` int(11) DEFAULT NULL, `log_data` int(11) DEFAULT NULL, `log_result` int(11) DEFAULT NULL, `log_level` int(11) DEFAULT NULL, `log_time` datetime NOT NULL, `log_previous` varchar(200) DEFAULT NULL, `log_now` varchar(200) DEFAULT NULL, `log_tag` int(11) DEFAULT NULL, `f1` varchar(100) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ''' % cls.platfrom_result_tmp_table_name #获取记录日志表 platfrom_result_log_table_sql = ''' CREATE TABLE IF NOT EXISTS `%s` like log_0_new ''' % cls.platfrom_result_log_table_name #创建保存数据的表和临时表 conn = Server.get_conn(0) cur = conn.cursor() try: cur.execute(platfrom_result_table_sql) except MySQLdb.Warning: pass try: cur.execute(platfrom_result_tmp_table_sql) except MySQLdb.Warning: pass try: cur.execute(platfrom_result_log_table_sql) except MySQLdb.Warning: pass conn.commit() conn.close()
def conference_send(id): audit_id = id result_msg = "" try: eran_all = 0 for model in Mail.objects.filter(id=int(audit_id)): playerIds = [] if model.player_id: playerIds = json.loads(model.player_id) if model.status == 1: result_status = False continue msg = {} if model.bonus_content: msg["rw"] = [{ "act": json.loads(model.bonus_content), "gn": "xx" }] dic = eval( DictValue.objects.get(dict_id=88).json_dict) ####### 变成字典 for i in msg["rw"][0]["act"]: single_earn = 0 if i["aID"] == 4: single_earn = i["v"] * int(dic[str( i["id"])].encode('gbk')) if i["aID"] == 3: single_earn = round(math.ceil(i["v"] / 1000)) if i["aID"] == 2 or i["aID"] == 1: single_earn = i["v"] eran_all += single_earn # if eran_all * playerIds.__len__() > chanel_earn: # return HttpResponse('操作不成功,你的发送余额不足') msg["m"] = model.content msg["t"] = model.title msg["ty"] = model.type if model.type == 0: msg["arg"] = playerIds elif model.type == 2: msg["arg"] = [] msg["svr"] = [-1] elif model.type == 3: msg["arg"] = model.channel_id msg["svr"] = [-1] server_id = model.server_ids print '==> msg: ', msg gmp = GMProtocol(server_id) result = gmp.send_mail(msg) if result == 0: model.status = 1 else: model.status = 2 result_status = True if result == 0 else False model.Auditor = str(model.Applicant) if model.time_status == 1: # 定时的邮件 model.time_status = 2 # 定时已审 model.order_time = datetime.datetime.now() model.save() # 获取当前渠道,然后减值 if result_status: #############获取当前渠道,然后减值 player_id = playerIds[0] sql = "select channel_id from player_%s where player_id =%s" % ( server_id, player_id) #############分服获取当前渠道 con = Server.get_conn(server_id) #######连接分服的数据库 cur = con.cursor() cur.execute(sql) res = cur.fetchone() if res[0]: oo = Channel.objects.filter(id=list(res)[0]).first() oo.allow_earn = oo.allow_earn - eran_all * playerIds.__len__( ) oo.save() else: model.time_status = 3 cur.close() con.commit() con.close() # 记录日志 remark2 = str(msg['arg']) if model.type == 2: remark2 = '全服角色' elif model.type == 3: remark2 = '联远商ID' # player_ids是个列表 if playerIds: for i in playerIds: gmp.save_log(model.Applicant, gmp.req_type, result, remark1=model.content, remark2=remark2, player_id=i) else: gmp.save_log(model.Applicant, gmp.req_type, result, remark1=model.content, remark2=remark2) result_msg += "发送成功" if result_status else "发送失败或已经发送过" except Exception, e: result_msg = trace_msg()
def conference_send_mail(request): '''公会邮件审核操作''' audit_ids = [int(request.REQUEST.get("id", '') or 0)] server_id = int(request.REQUEST.get("server_id", "") or 0) result_msg = "" if request.method == 'POST': # 批量发送 audit_ids = request.REQUEST.get("ids", "") if audit_ids: audit_ids = json.loads(audit_ids) result_msg = "批量" if not audit_ids: result_msg = "无此ID或已发送" return HttpResponse(result_msg) try: ##################全部的价值,这里来判断是否可以审核 # cha_list = list(request.admin.role.first().resource_ids['channel']) for audit_id in audit_ids: # channel_li = Channel.objects.filter(id__in=cha_list) # chanel_earn = 0 # for v in channel_li: # chanel_earn += v.allow_earn ########################用户的运行的全部价值 eran_all = 0 for model in Mail.objects.filter(id=int(audit_id)): playerIds = [] if model.player_id: playerIds = json.loads(model.player_id) if model.status == 1: result_status = False continue msg = {} moch = model.channel_id channel_si = Channel.objects.filter(id=int(moch))[0] print channel_si.allow_earn if model.bonus_content: msg["rw"] = [{"act": json.loads(model.bonus_content), "gn": "xx"}] #################################### dic = eval(DictValue.objects.get(dict_id=88).json_dict) ####### 变成字典 for i in msg["rw"][0]["act"]: single_earn = 0 if i["aID"] == 4: single_earn = i["v"] * int(dic[str(i["id"])].encode('gbk')) if i["aID"] == 3: single_earn = math.ceil(i["v"] / 1000) if i["aID"] == 2 or i["aID"] == 1: single_earn = i["v"] eran_all += single_earn if eran_all * playerIds.__len__() > channel_si.allow_earn: return HttpResponse('操作不成功,渠道 %s 发送余额不足' % (channel_si.name)) # print 'pppppp',eran_all * playerIds.__len__(),channel_si.allow_earn msg["m"] = model.content msg["t"] = model.title msg["ty"] = model.type if model.type == 0: msg["arg"] = playerIds elif model.type == 2: msg["arg"] = [] msg["svr"] = [-1] elif model.type == 3: msg["arg"] = model.channel_id msg["svr"] = [-1] server_id = model.server_ids print '==> msg: ', msg gmp = GMProtocol(server_id) result = gmp.send_mail(msg) if result == 0: model.status = 1 else: model.status = 2 result_status = True if result == 0 else False model.Auditor = str(request.admin.id) if model.time_status == 1: model.time_status = 0 model.order_time = datetime.datetime.now() model.save() # 获取当前渠道,然后减值 if result_status: #############获取当前渠道,然后减值 player_id = playerIds[0] sql = "select channel_id from player_%s where player_id =%s" % ( server_id, player_id) #############分服获取当前渠道 con = Server.get_conn(server_id) #######连接分服的数据库 cur = con.cursor() cur.execute(sql) res = cur.fetchone() if res[0]: oo = Channel.objects.filter(id=list(res)[0]).first() oo.allow_earn = oo.allow_earn - eran_all * playerIds.__len__() oo.save() cur.close() con.commit() con.close() # 记录日志 remark2 = str(msg['arg']) if model.type == 2: remark2 = '全服角色' elif model.type == 3: remark2 = '联远商ID' # player_ids是个列表 if playerIds: for i in playerIds: gmp.save_log(request.admin.id, gmp.req_type, result, remark1=model.content, remark2=remark2, player_id=i) else: gmp.save_log(request.admin.id, gmp.req_type, result, remark1=model.content, remark2=remark2) result_msg += "发送成功" if result_status else "发送失败或已经发送过" except Exception, e: result_msg = trace_msg()
def getConn(server_id=0): return Server.get_conn(server_id)
def server_status_edit(request): _r = {"code": 1} action = request.REQUEST.get('action', '') server_list = request.POST.getlist('sid') last_time = datetime.datetime.now() if not server_list: return HttpResponse('没有选择服务器!') try: datas = Server.objects.filter(id__in=server_list) if action == 'change_status': # 修改服务器状态 status = int(request.POST.get('serv_status', '') or 0) datas.using('write').update(status=status, last_time=last_time) if status == 1: post_tip = request.POST.get('weihuTip', '') datas.using('write').update(remark=post_tip, last_time=last_time) elif action == 'change_version': # 修改服务器版本 ver = request.POST.get('ver', '') datas.using('write').update(client_ver=ver, last_time=last_time) elif action == 'clear_server': # 清档 not_maintenance = False limit_player = False for s in datas: if s.status not in [ Server.Status.MAINTENANCE, Server.Status.DELETED ]: not_maintenance = True break sql = 'select count(id) from player_%s' % (s.id) conn = Server.get_conn(s.id) cursor = conn.cursor() cursor.execute(sql) result = cursor.fetchone() if int(result[0]) >= 100: limit_player = True break if not_maintenance: return HttpResponse( json.dumps({ "code": 1, "msg": "%s 不是维护状态!" % s.id })) if limit_player: return HttpResponse( json.dumps({ "code": 1, "msg": "%s 角色数超100!" % s.id })) clear_server_url = 'http://oms.shyouai.com/Net_api?' postData = get_clear_server_params(server_list) if not postData: return HttpResponse( json.dumps({ "code": 1, "msg": "服务器开服时间有问题!" })) clear_server_url += postData print clear_server_url result = requests.get(clear_server_url, timeout=150).json() print result _r["code"] = 0 if result["status"] == 0 else 1 if not result: _r["msg"] = "运维无法返回结果!" return HttpResponse(json.dumps(_r)) if _r["code"] == 1: _r["msg"] = "校验失败!" return HttpResponse(json.dumps(_r)) _r["msg"] = [] for s in result["result"]: if s['status'] == 1: _r["msg"].append(s['server_id']) if _r["msg"]: _r["msg"] = json.dumps(_r["msg"]) + ' 清档失败' else: _r["msg"] = "全部清档成功" return HttpResponse(json.dumps(_r)) _r["code"] = 0 _r["msg"] = '修改成功!' except: _r["msg"] = trace_msg() return HttpResponse(json.dumps(_r))
def player_list(request): '''玩家列表 ''' server_id = int(request.REQUEST.get('server_id', '') or 0) player_id = int(request.REQUEST.get('player_id', '') or 0) single = request.REQUEST.get("type", "") query_name = '玩家角色管理' charge_map = DictDefine.get_dict_for_key("recharge_type") request.POST.setlist("charge_map", charge_map.values()) print '玩家角色管理', request.POST.getlist('server_id', '') request.has_shutup = True if server_id: shutup_player_list = {} gmp = GMProtocol(server_id) result = gmp.player_shutup_list(0) resutl = json.dumps(result) for l in result[0]: try: timestamp_to_datetime_str(l[2]) except Exception as e: l[2] = l[1] + max_time shutup_player_list[l[0]] = [ timestamp_to_datetime_str(l[1]), timestamp_to_datetime_str(l[2]) ] player_ids = shutup_player_list.keys() if server_id and player_id and single == 'single': conn = Server.get_conn(server_id) cur = conn.cursor(cursorclass=MySQLdb.cursors.DictCursor) sql = """select '',p.player_id,%s,p.player_name,CONVERT(IFNULL(pp.log_level,'1'),SIGNED) level,p.channel_id,p.other,p.user_type,p.link_key,p.login_num,p.mobile_key,p.last_time,p.last_ip,p.create_time,p.status , '' as action from player_%s p LEFT JOIN ( select log_user,MAX(log_level) as log_level from log_player_level group by log_user ) pp ON p.player_id=pp.log_user where player_id = %s""" % ( server_id, server_id, player_id) cur.execute(sql) player = cur.fetchone()[0] conn.close() if player: last_time = player["last_time"].strftime('%Y-%m-%d %H:%M:%S') create_time = player["create_time"].strftime('%Y-%m-%d %H:%M:%S') for t in Player.TYPE_CHOICES: if player["user_type"] == t[0]: user_type = t[1] for s in Player.STATUS_CHOICES: if player["status"] == s[0]: status = s[1] request.playerData = [[ "", player["player_id"], server_id, player["player_name"], player["level"], player["channel_id"], player["other"], user_type, player["link_key"], player["login_num"], player["mobile_key"], last_time, player["last_ip"], create_time, status, "" ]] def list_data_handle(list_data): new_list_data = [] for p in request.playerData: if p[1] in player_ids: new_list_data.append( list(p) + shutup_player_list.get(player_id, [0, 0])) if new_list_data: return new_list_data return request.playerData return query_view(request, query_name=query_name, list_data_handle=list_data_handle) if request.REQUEST.get('is_shutup', ''): try: player_ids = player_ids or [1] request.POST.setlist('player_id', player_ids) print shutup_player_list def list_data_handle(list_data): new_list_data = [] for row in list_data: player_id = row[1] new_list_data.append( list(row) + shutup_player_list.get(player_id, [0, 0])) return new_list_data return query_view(request, query_name=query_name, list_data_handle=list_data_handle) except: err_msg = trace_msg() return HttpResponse('{"code":-1,"msg":"%s"}' % err_msg) else: try: def list_data_handle(list_data): new_list_data = [] for row in list_data: player_id = row[1] if player_id in player_ids: new_list_data.append( list(row) + shutup_player_list.get(player_id)) else: new_list_data.append(list(row)) return new_list_data return query_view(request, query_name=query_name, list_data_handle=list_data_handle) except: err_msg = trace_msg() return HttpResponse('{"code":-1,"msg":"%s"}' % err_msg) return query_view(request, query_name)