def main1(): fname = utils.filter_from_origin('SecSNSGetFlow') print(fname) with utils.utf8_open(fname) as fr: for line in fr: if gbid1 in line and gbid2 in line: print(line)
def guide_flow(): fname = utils.filter_from_origin('GuideFlow') id_dic = {} avatar_count = utils.get_avatar_count() with utils.utf8_open(fname) as fr: for line in fr: lo = LogOne.get_log_from_line(line) if not lo: continue id_dic.setdefault(lo.guide_id, set()) id_dic[lo.guide_id].add(lo.gbid) rets = [(int(k), len(v)) for k, v in id_dic.items()] rets.sort(key=lambda x: x[0]) csv = csv_output.CSVOutPut() csv.set(0, 0, '节点') csv.set(0, 1, '创角数') csv.set(0, 2, '节点通过人数') csv.set(0, 3, '节点通过率') idx = 1 for key, num in rets: csv.set(idx, 0, key) csv.set(idx, 1, avatar_count) csv.set(idx, 2, num) csv.set(idx, 3, num / avatar_count) idx += 1 out_name = utils.get_out_name('out', 'guide_flow.csv') csv.output(out_name)
def parse_lingxu(): fname = utils.filter_from_origin(LogOne.LingxuAttackFlow.FILTER_STR) with utils.utf8_open(fname) as fr: for line in fr: lo = LogOne.get_log_from_line(line) if lo.gbid == '8444553113334133613': print(line)
def get_header(): dic = {} fname = utils.filter_from_origin('PlayerLogout') with utils.utf8_open(fname) as fr: for line in fr: lo = LogOne.get_log_from_line(line) if not lo: continue uk = lo.unique_key() if uk in dic: dic[uk].update_level(lo.level, lo.battle_point) else: dic[uk] = NewBieLeft(uk, lo.level, lo.login_channel, lo.battle_point) csv = csv_output.CSVOutPut() csv.set(0, 0, 'GOPENID') csv.set(0, 1, '等级') csv.set(0, 2, '战力') csv.set(0, 3, '渠道号') idx = 1 for lo in dic.values(): if lo.level > const.MAX_LEFT_LEVEL: continue csv.set(idx, 0, f'{lo.open_id}\'') csv.set(idx, 1, lo.level) csv.set(idx, 2, lo.battle_point) csv.set(idx, 3, lo.login_channel) idx += 1 fname = utils.get_out_name('out', 'left_newbie_header.csv') csv.output(fname)
def main2(): fname = utils.filter_from_origin('PlayerFriendsList') print(fname) with utils.utf8_open(fname) as fr: for line in fr: log_one = LogOne.get_log_from_line(line) if log_one.gbid == gbid2: print(log_one.time_str, log_one.friend_gbid, log_one.friend_name)
def parse_guild(): fname = utils.filter_from_origin(LogOne.GuildFlow.FILTER_STR) with utils.utf8_open(fname) as fr: for line in fr: lo = LogOne.get_log_from_line(line) if not lo: continue if lo.gbid == '8444553112797262642': print(lo.act_type) print(line)
def filter_item_flow_by_src(src): fw_name = utils.get_out_name('tmp', f'itme_flow_{src}.log') if os.path.exists(fw_name): return fw_name fname = utils.filter_from_origin(LogOne.ItemFlow.FILTER_STR) fw = utils.utf8_open(fw_name, 'w') with utils.utf8_open(fname) as fr: for line in fr: lo = LogOne.get_log_from_line(line) if lo.src != src: continue fw.write(line) fw.close() return fw_name
def parse_by_act(filt, act_id): fname = filt.filter_by_act(act_id) f = Filter.Filter(fname, LogOne.RoundFlow) fname = f.filter_inner() parse_file(fname, '{}.{}.csv'.format(act_id, 'inner')) fname = f.filter_out() parse_file(fname, '{}.{}.csv'.format(act_id, 'outter')) if __name__ == '__main__': # whole_log = r'E:\shLog\tlog\xzj.log.LOG_GUILD_BANDIT.log' print(1) fname = utils.filter_from_origin('RoundFlow') print(2) f = Filter.Filter(fname, LogOne.RoundFlow) print(3) # parse_by_act(f, 9) print(4) fname = f.filter_by_act(20) print(5) with utils.utf8_open(fname, encoding='utf-8') as fr: for line in fr: lo = LogOne.RoundFlow.get_log_obj_from_line(line) if int(lo.round_time) > 1800: print(lo.result) # parse_by_act(f, 32000004) # f = Filter.Filter(whole_log, filter_inner_name, filter_out_name)
self.uk_day_dict.setdefault(day, {}) self.uk_day_dict[day][uk] = max( self.uk_day_dict[day].get(uk, 0), int(lo.score)) def out_as_csv(self, filename): out_dir = utils.get_dir('out') out_name = os.path.join(out_dir, filename) csv = csv_output.CSVOutPut() index = 0 for day, day_dict in self.uk_day_dict.items(): sum_score = sum(day_dict.values()) csv.set(0, index, day) csv.set(1, index, sum_score / len(day_dict)) csv.set(2, index, sum_score) csv.set(3, index, len(day_dict)) index += 1 csv.output(out_name) if __name__ == '__main__': fname = utils.filter_from_origin('LOG_GUILD_TRAIN') f = Filter.Filter(fname, None) fname = f.filter_out() gt = GuildTrain(fname) gt.parse() gt.out_as_csv('guild_train_out_first.csv')
day_dict = self.days[day] levelDict = {} for unique_key, lo in day_dict.items(): levelDict.setdefault(lo.level, []) levelDict[lo.level].append(lo) levelList = list(levelDict.keys()) levelList.sort() for _index, level in enumerate(levelList): num = len(levelDict[level]) csv.set(_index + 1, index * 2, str(level)) csv.set(_index + 1, index * 2 + 1, str(num)) csv.output(out_name) if __name__ == '__main__': fname = utils.filter_from_origin('SecLogout') f = Filter.Filter(fname, LogOne.LogOut) fname = f.filter_inner() lo = LogOut(fname) lo.parse() lo.out_as_csv('log_out_inner.csv') fname = f.filter_out() lo = LogOut(fname) lo.parse() lo.out_as_csv('log_out_out_first.csv')
fname = Filter.Filter.filter_login_log() filt = Filter.Filter(fname, None) print('-------------------------------------- 内部玩家次留统计') tmp_log_name = filt.filter_inner() out_name = utils.get_out_name('out', 'daily_inner.csv') parse_tlog.parse_tlog(tmp_log_name, out_name) print('-------------------------------------- 外部玩家次留统计') tmp_log_name = filt.filter_out() out_name = utils.get_out_name('out', 'daily_outer.csv') parse_tlog.parse_tlog(tmp_log_name, out_name) print('-------------------------------------- 帮盗统计') fname = utils.filter_from_origin('RoundFlow') f = Filter.Filter(fname, LogOne.RoundFlow) guild_bandit.parse_by_act(f, 9) print('-------------------------------------- 帮会修炼') fname = utils.filter_from_origin('GuildTrainFlow') f = Filter.Filter(fname, None) fname = f.filter_out() gt = guild_train.GuildTrain(fname) gt.parse() gt.out_as_csv('guild_train_out_first.csv') print('-------------------------------------- 日留') fname = Filter.Filter.filter_login_log() f = Filter.Filter(fname, None)
import utils import const if __name__ == '__main__': fname = utils.filter_from_origin('GuildFlow') fname = utils.filter_from_origin('LOG_GUILD_MEMBER_OPR') fname = utils.filter_from_origin('LOG_GUILD_OPR')