Example #1
0
 def __init__(self):
     # conf path
     self.conf_path = ConfParameters.ConfParameters().conf_path
     # initial mysql-db
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'],
                               mysql_para['password'],
                               mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     self.stat_pay = mysql_para['stat_pay']
     self.stat_base = mysql_para['stat_base']
     self.user_active_openid = mysql_para['user_active_openid']
     # initial xls writer
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local parameter
     self.compute_date = '2018-09-13'
     self.limit_num = '100'
     self.eighteen_ships = self.__list_to_str([
         1001, 1002, 1003, 2001, 2002, 2003, 2004, 2005, 3001, 4001, 4002,
         4003, 4004, 3004, 4030
     ])
     self.sixteen_ships = self.__list_to_str(
         [1004, 1005, 1006, 1007, 2007, 4005, 4008, 4009, 4013, 3005, 4031])
     self.fifteen_ships = self.__list_to_str([
         1008, 2006, 2008, 2009, 2010, 2011, 3002, 3003, 4006, 4007, 4010,
         4011, 4012, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020,
         5021, 5022, 5025
     ])
     file_name = self.conf_path + 'ship_exclusive.txt'
     self.ship_table = ReadTable.ReadTable(file_name).read_table_file()
Example #2
0
 def __init__(self):
     conf = ConfParameters.ConfParameters().log_conf
     self.log_path = conf['game_log_path_current']
     self.world_path = conf['world_log_path']
     self.start_date = '2018-08-17'
     self.end_date = '2018-08-26'
     self.period = '1'
     # data
     # {uid:{world:world,rank:rank,item1:count1,other_attr...}}
     self.top_map = dict()
     self.item_list = [
         '50064', '50023', '50060', '50044', '50045', '50046', '50047',
         '40049', '50030'
     ]
     self.item_dict = dict(
     )  # here keep the maximum item count which users are capable to exchange
     self.__load_item()
     # initial mysql-db
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'],
                               mysql_para['password'],
                               mysql_para['stat_base'])
     self.stat_pay = mysql_para['stat_pay']
     self.stat_base = mysql_para['stat_base']
     self.user_reg = mysql_para['stat_userreg']
     self.user_active_openid = mysql_para['user_active_openid']
     self.cursor = self.db.cursor()
     # initial xls writer
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     # user info check
     self.user_info = UserInfoCheck.UserInfoCheck(self.cursor)
 def __init__(self):
     # initial mysql
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(host=mysql_para['ip'],
                               port=mysql_para['port'],
                               user=mysql_para['users'],
                               passwd=mysql_para['password'],
                               db=mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     self.act_stat_base = mysql_para['stat_base']
     self.reg_stat_base = mysql_para['stat_userreg']
     self.pay_base = mysql_para['stat_pay']
     #initial rate
     self.current_rate = ConfParameters.ConfParameters().current_rate
     # self.levellist = [0, 1000, 2000, 3000, 4000, 5000]
     self.levellist = [
         0, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000,
         250000, 500000, 1000000
     ]
     # initial EasyXls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local parameter
     self.date_list = list()
     self.channel_list = list()
     self.zone_list = list()
     self.input_dict = dict()
     self.__load_input()
Example #4
0
 def __init__(self):
     # self.conf_path = ConfParameters.ConfParameters().conf_path
     # initialize
     # # mysql
     # mysql_para = ConfParameters.ConfParameters().mysql_conf
     # self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'], mysql_para['password'],
     #                           mysql_para['stat_pay'])
     #bigdata
     mysqlStatInfo = {
         'host': '10.66.127.43',
         'port': 3306,
         'user': '******',
         'passwd': 'r00tr00t'
     }
     self.db = MySQLdb.connect(host=mysqlStatInfo['host'],
                               port=mysqlStatInfo['port'],
                               user=mysqlStatInfo['user'],
                               passwd=mysqlStatInfo['passwd'],
                               db='modernship_gf_stat_base',
                               charset='utf8')
     self.cursor = self.db.cursor()
     self.easy_mysql = EasyMysql.EasyMysql()
     # # xls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
Example #5
0
 def __init__(self):
     #bigdata
     mysqlStatInfo = {'host': '10.66.127.43', 'port': 3306, 'user': '******', 'passwd': 'r00tr00t'}
     self.db = MySQLdb.connect(host=mysqlStatInfo['host'], port=mysqlStatInfo['port'], user=mysqlStatInfo['user'],
                               passwd=mysqlStatInfo['passwd'], db='modernship_gf_stat_base', charset='utf8')
     self.cursor = self.db.cursor()
     self.easy_mysql = EasyMysql.EasyMysql()
     # # xls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
Example #6
0
 def run_date_list(self):
     date_list = DateList.DateList().get_date_list(self.start_date,
                                                   self.end_date)
     sheet_name = self.start_date + '_' + self.end_date
     sheet = self.wbk.add_sheet(unicode(sheet_name), cell_overwrite_ok=True)
     xls_writer = EasyXls.EasyXls()
     head_line = [
         '设备类型', '新增设备数', '通过启动加载项设备数', '开启新手引导设备数', '通过新手引导设备数',
         '启动加载项通过率', '新手引导通过率'
     ]
     line_num = [0]
     xls_writer.insert_xls(head_line, sheet, line_num)
     total_result = dict()
     device_list = list()
     for date in date_list:
         tmp_map = self.join_maps(date)
         for device in tmp_map.keys():
             if device not in device_list:
                 device_list.append(device)
             if device not in total_result.keys():
                 total_result[device] = dict()
             total_result[device][
                 'web_resp'] = total_result[device].setdefault(
                     'web_resp', 0) + tmp_map[device]['web_resp']
             total_result[device][
                 'game_conn'] = total_result[device].setdefault(
                     'game_conn', 0) + tmp_map[device]['game_conn']
             total_result[
                 device]['guide'] = total_result[device].setdefault(
                     'guide', 0) + tmp_map[device]['guide']
             total_result[device][
                 'pass_guide'] = total_result[device].setdefault(
                     'pass_guide', 0) + tmp_map[device]['pass_guide']
     device_list = sorted(device_list,
                          key=lambda x: -1 * total_result[x]['web_resp'])
     for device in device_list:
         web_resp = total_result[device].setdefault('web_resp', 0)
         game_conn = total_result[device].setdefault('game_conn', 0)
         guide = total_result[device].setdefault('guide', 0)
         pass_guide = total_result[device].setdefault('pass_guide', 0)
         rate1 = 0
         rate2 = 0
         if web_resp > 0:
             rate1 = str(int(1000 * game_conn / web_resp) / 10.0) + '%'
         if guide > 0:
             rate2 = str(int(1000 * pass_guide / guide) / 10.0) + '%'
         data_list = [
             device, web_resp, game_conn, guide, pass_guide, rate1, rate2
         ]
         xls_writer.insert_xls(data_list, sheet, line_num)
Example #7
0
 def __init__(self, compute_date):
     self.compute_date = compute_date
     # conf path
     self.conf_path = ConfParameters.ConfParameters().conf_path
     # initial mysql-db
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'],
                               mysql_para['password'],
                               mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     # initial xls writer
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.borders = xlwt.Borders()
     self.style = xlwt.XFStyle()
     self.__load_borders()
     self.style.borders = self.borders
     # local parameter
     self.ship_table = dict()
     self.read_table()
     self.ship_table_name = 'user_ship_info'
     self.missile_table_name = 'user_missile_info'
     self.eighteen_ships = [
         1001, 1002, 1003, 2001, 2002, 2003, 2004, 2005, 3001, 4001, 4002,
         4003, 4004, 3004, 4030
     ]
     self.sixteen_ships = [
         1004, 1005, 1006, 1007, 2007, 4005, 4008, 4009, 4013, 3005, 4031
     ]
     self.fifteen_ships = [
         1008, 2006, 2008, 2009, 2010, 2011, 3002, 3003, 4006, 4007, 4010,
         4011, 4012, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019, 5020,
         5021, 5022, 5025
     ]
     self.zoneid_list_0512 = [
         10001, 40001, 20001, 40002, 20002, 30001, 20003, 30002, 20004,
         40003, 10002, 20005, 30003, 20006, 20007, 30004, 20008, 20009,
         20010, 30005, 20011, 20012, 20013, 20014, 30006, 40004, 10003,
         20015, 10004, 20016, 20017, 40005, 20018, 10005, 20019, 20020
     ]
     self.zoneid_list_0731 = [
         20021, 30007, 20022, 20023, 20024, 40006, 20025, 20026, 20027,
         10006, 20028, 30008, 20029, 20030, 40007, 20031, 20032, 20033,
         20034
     ]
     self.zoneid_list_0913 = [
         20035, 30009, 40008, 10007, 20036, 20037, 20038, 20039, 20040,
         20041, 50001, 20042, 10008, 20043, 55001, 20044, 20045, 20046,
         30010, 40009, 20047, 55002, 20048, 55003, 55004
     ]
Example #8
0
 def __init__(self):
     # initial mysql
     mysql_para = ConfParameters.ConfParameters().mysql_conf_bd
     self.db = MySQLdb.connect(host=mysql_para['ip'], user=mysql_para['users'],
                               passwd=mysql_para['password'], db=mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     # initial xls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local
     self.stat_jp = 'zhanguo_jp_stat_base'
     self.stat_tw = 'zhanguo_stat_base'
     self.key_list = ['Login','Logout','InstanceBattle','QuickInstance','CreateBuilding','GetCity','March','FinishBattle']
Example #9
0
 def __init__(self):
     # conf path
     self.conf_path = ConfParameters.ConfParameters().conf_path
     # initial mysql-db
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'],
                               mysql_para['password'],
                               mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     # initial xls writer
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local parameter
     self.start_date = '2018-06-01'
     self.end_date = '2018-09-17'
Example #10
0
 def __init__(self, start_date, end_date):
     # initial mysql
     mysql_para = ConfParameters.ConfParameters().mysql_conf_bd
     self.db = MySQLdb.connect(host=mysql_para['ip'],
                               user=mysql_para['users'],
                               passwd=mysql_para['password'],
                               db=mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     # initial xls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local
     self.stat_jp = 'zhanguo_jp_stat_base'
     self.stat_tw = 'zhanguo_stat_base'
     self.start_date = start_date
     self.end_date = end_date
Example #11
0
 def __init__(self):
     # initial mysql-db
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'], mysql_para['password'], mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     # initial xls writer
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.borders = xlwt.Borders()
     self.style = xlwt.XFStyle()
     self.__load_borders()
     self.style.borders = self.borders
     # local parameter
     self.key_level = 'level'
     self.key_vip = 'vip_level'
     self.table_name = 'user_reten_lv_vip'
     self.start_date = '2018-03-28'
     self.end_date = '2018-09-22'
Example #12
0
 def __init__(self, start_date, end_date, *channel):
     # conf path
     self.conf_path = ConfParameters.ConfParameters().conf_path
     # initial mysql-db
     self.mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.stat_base = self.mysql_para['stat_base']
     self.db = None  # such is initiate not in constructor but when actually used to ensure db get closed after connect
     self.cursor = None
     # initial xls writer
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local parameter
     self.start_date = start_date
     self.end_date = end_date
     self.channel = '-1'
     self.period_limit = '30'
     if len(channel) > 0:
         self.channel = channel[0]
 def __init__(self):
     # initial mysql
     mysql_para = ConfParameters.ConfParameters().mysql_conf_bd
     self.db = MySQLdb.connect(host=mysql_para['ip'],
                               port=mysql_para['port'],
                               user=mysql_para['users'],
                               passwd=mysql_para['password'],
                               db=mysql_para['stat_base'])
     self.cursor = self.db.cursor()
     # initial EasyXls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # local parameter
     self.date_list = list()
     self.channel_list = list()
     self.zone_list = list()
     self.input_dict = dict()
     self.__load_input()
Example #14
0
 def __init__(self):
     # environment
     self.conf_path = ConfParameters.ConfParameters().conf_path
     # initialize
     # # mysql
     mysql_para = ConfParameters.ConfParameters().mysql_conf
     self.db = MySQLdb.connect(mysql_para['ip'], mysql_para['users'],
                               mysql_para['password'],
                               mysql_para['stat_pay'])
     self.cursor = self.db.cursor()
     self.easy_mysql = EasyMysql.EasyMysql()
     # # xls
     self.wbk = xlwt.Workbook()
     self.xls_writer = EasyXls.EasyXls()
     self.style = xlwt.XFStyle()
     self.style.borders = self.xls_writer.borders
     # # others
     self.easy_date = DateList.DateList()
     # local
     self.cycle = 7
     vip_file_name = self.conf_path + 'Vip_Money.txt'
     self.vip_dict = self.__get_vip_table(vip_file_name)
Example #15
0
def write_standard_form(res_dict,sheet,line_num,style):
    is_legal_output(res_dict)
    data_dict = res_dict['data_dict']
    X_list = res_dict['X_list']
    Y_list = res_dict['Y_list']
    head_name = res_dict['head_name']
    default_value = res_dict['default_value']
    X_trans = res_dict.setdefault('X_trans', dict())
    Y_trans = res_dict.setdefault('Y_trans', dict())

    easy_xls = EasyXls.EasyXls()
    head_list = list()
    head_list.append(head_name)
    for X in X_list:
        head_list.append(X_trans.setdefault(X, X))
    easy_xls.insert_xls_style(head_list, sheet, line_num, style)
    for Y in Y_list:
        data_list = list()
        data_list.append(Y_trans.setdefault(Y, Y))
        for X in X_list:
            data_list.append(data_dict.setdefault(Y, dict()).setdefault(X, default_value))
        easy_xls.insert_xls_style(data_list, sheet, line_num, style)
Example #16
0
                rate = float(pass_uid) / total_user
            tmp_list.append(pass_uid)
            tmp_list.append(rate)
            data_list.append(tmp_list)
        return data_list


# main
if __name__ == '__main__':
    # start_date = sys[1]
    # end_date = sys[2]
    start_date = '2018-09-26'
    end_date = '2018-09-27'
    # initiate xls
    wbk = xlwt.Workbook()
    xls_writer = EasyXls.EasyXls()
    style = xlwt.XFStyle()
    style.borders = xls_writer.borders
    # get log data
    log_user_guide = LogUserGuide(start_date, end_date)
    file_str = log_user_guide.log_file_str()
    cmd = 'grep -h -s \'' + log_user_guide.key_word + '\' ' + file_str + '|awk -F \',\' \'{if($1>="2018-09-25 12:00:00")max[$3]=$15} END {OFS=",";for(i in max)print i,max[i]}\'|awk -F \',\' \'{sum[$2]=sum[$2]+1} END {OFS=",";for(k in sum)print k,sum[k]}\''
    data_list = log_user_guide.analyse_log(log_user_guide.cmd_compute(cmd))
    # write xls
    sheet = xls_writer.new_sheet('sheet1', wbk)
    line_num = [0]
    head_line = ['编号', '翻译', '人数', '比例']
    xls_writer.insert_xls_style(head_line, sheet, line_num, style)
    for data_line in data_list:
        xls_writer.insert_xls_style(data_line, sheet, line_num, style)
    # save xls