# from time import time # from types import new_class # from pandas.io import parsers # import xlrd # import os # import shutil # import re # import sys # import json # import numpy as np from pandas import DataFrame; import pandas as pd import analyze.AnalyzeFuc as anlyze from common.CommonFuc import DateToTime from parsers.BillParser import BillParser from parsers.BdcParser import BdcParser from parsers.BdcCliParser import BdcCliParser TA_PATH = "./ta/" import datetime Bill_Log_Path = "./log/bill/" Bdc_Log_Path = "./log/bdcSvr/" BdcCli_Log_Path = "./log/bdcCli/" def ParserAllLog(args): ParserBillLog(args) ParserBdcLog(args) ParserBdcCliLog(args) #解析bill #@date 分析日期 #@day 天数 def ParserBillLog(args): date = args[0] day = int(args[1]) if len(args) == 2 else 1 starTime = datetime.datetime.strptime(date, '%Y-%m-%d') for i in range(0, day): delta = datetime.timedelta(days=i) curtime = starTime + delta parser = BillParser(curtime, Bill_Log_Path) parser.Parsers() #解析bdc #@date 分析日期 #@day 天数 def ParserBdcLog(args): date = args[0] day = int(args[1]) if len(args) == 2 else 1 starTime = datetime.datetime.strptime(date, '%Y-%m-%d') for i in range(0, day): delta = datetime.timedelta(days=i) curtime = starTime + delta parser = BdcParser(curtime, Bdc_Log_Path) parser.Parsers() #解析bdcCli #@date 分析日期 #@day 天数 def ParserBdcCliLog(args): date = args[0] day = int(args[1]) if len(args) == 2 else 1 starTime = datetime.datetime.strptime(date, '%Y-%m-%d') for i in range(0, day): delta = datetime.timedelta(days=i) curtime = starTime + delta parser = BdcCliParser(curtime, BdcCli_Log_Path) parser.Parsers() def MainlineFinishOnline(args): date = args[0] day = int(args[1]) if len(args) == 2 else 1 mainlandData = anlyze.CalcMainlineFinishOnline(date, day) mainlandData.to_csv(f"./out/MainlineFinishOnline_{date}_{day}.csv", index=False) def MainlandStateOnline(args): date = args[0] day = int(args[1]) if len(args) >= 2 else 1 svrver_id = int(args[2]) if len(args) >= 3 else 0 mainlandData = anlyze.CalcMainlandStateOnline(date, day, svrver_id) mainlandData.to_csv(f"./out/MainlandStateOnline_{date}_{day}_{svrver_id}.csv", index=False) def PlayerBillData(args): uid = int(args[0]) billtype = int(args[1]) date = args[2] day = int(args[3]) if len(args) == 4 else 1 data = anlyze.CalcPlayerBillData(uid, billtype, date, day) data.to_csv(f"./out/{uid}_{billtype.name}_{date}_{day}.csv", index=False) def HangupTime(args): date = args[0] day = int(args[1]) if len(args) == 2 else 1 data1, data2 = anlyze.CalcHangupTime(date, day) def CalcPlayerStayUIData(): starTime = DateToTime("2021-10-03") players = pd.read_csv("./csv/付费礼包.csv") list = [] for i in range(0, len(players)): player = players.iloc[i] endTtime = datetime.datetime.strptime(player["事件时间"], "%Y/%m/%d %H:%M") _data = anlyze.CalcPlayerStayUI(player["账户ID"], starTime, endTtime) list.append(_data) #players["mainland"] = players.apply(lambda x : anlyze.GetPlayerMaxMainland(x["账户ID"], x["事件时间"]), axis=1) #players.to_csv(f"./out/付费礼包.csv", index=False) data = pd.concat(list) data.to_csv(f"./out/玩家停留界面.csv", index=False) CMD_MAP = {} def Register(cmd:str, helpStr:str, func): one = { "cmd" : cmd, "help": helpStr, "func":func } CMD_MAP[cmd] = one def Help(args): print("Help--------------------------------------------------------------------Star\n") for value in CMD_MAP.values(): cmd = value["cmd"] help = value["help"] print(f"{cmd}\t\t\t\t-----{help}\n") print("Help--------------------------------------------------------------------End\n") #end Help def RegisterAll(): Register("ParserAllLog", "解析所有日志 {date} {day}", ParserAllLog) Register("ParserBillLog", "解析billlog ParserBillLog {date} {day}", ParserBillLog) Register("ParserBdcLog", "解析bdclog ParserBdcLog {date} {day}", ParserBdcLog) Register("ParserBdcCliLog", "解析bdcClilog ParserBdcCliLog {date} {day}", ParserBdcCliLog) Register("PlayerBillData", "拉取玩家bill日志 PlayerBillData {uid} {billtype} {date} day", PlayerBillData) Register("MainlandStateOnline", "计算玩家在线时长 MainlandStateOnline {date} {day} {server_id}", MainlandStateOnline) Register("help", "帮助", Help) #end RegisterAll if __name__ == "__main__": #CalcPlayerStayUIData() #anlyze.CalcHangupTime("2021-10-03", 1) RegisterAll() while True: argsStr = input("输入指令:") args = argsStr.split(" ") if len(args) == 0: print("输入为空") continue cmd = args[0] if cmd == "quit": break if cmd in CMD_MAP.keys(): one = CMD_MAP[cmd] one["func"](args[1:]) else: print("没有该命令.....")