def statistics(self, list_str): # 获取当前时间 # tz = pytz.timezone('Asia/Shanghai') # current_time = str(datetime.datetime.now(tz))[0:16] # 获取当前的create_time的数字 current_create_time = list_str[3][11:16] current_create_time = int(current_create_time[0:2] + current_create_time[3:6]) current_create_time = current_create_time # 打开ini文件 result = self.open_ini_result_object() # 如果没有检查过 if result['is_check'] == 0: # 当当前创建时间超过早上9点的时候记录当前、当前前一天、当前前一天的一天的id if ((current_create_time >= 915) and (current_create_time <= 1000)): result['is_check'] = 1 num1 = str(int(list_str[0]) - int(result["today_id"])) num1_perhour = str( round((int(list_str[0]) - int(result["today_id"])) / 24, 1)) result['pre_pre_day_id'] = result['pre_day_id'] result['pre_day_id'] = result["today_id"] result['today_id'] = list_str[0] info = "过去一天有" + num1 + "个词条,平均一小时" + num1_perhour + "个" pop(bar_pop, [2, '更新统计:' + info]) send_statics_email(info) self.write_str_result_to_ini(result) if current_create_time > 1000: result['is_check'] = 0 self.write_str_result_to_ini(result) # 得到早上到目前的创建词条数 today_num = str(int(list_str[0]) - int(result["today_id"])) # 得到早上到现在平均每小时多少个词 sub_minute = (current_create_time - 915) / 60 if sub_minute == 0: # 防止sub_minute=0 sub_minute = 1 today_persent = str(round(int(today_num) / sub_minute, 1)) # 前一天总数 pre_num = str(int(result["today_id"]) - int(result['pre_day_id'])) # 前一天平均 pre_persent = str(round(int(pre_num) / 24, 1)) # 大前天总数 pre_pre_num = str( int(result['pre_day_id']) - int(result['pre_pre_day_id'])) # 大前天平均 pre_pre_persent = str(round(int(pre_pre_num) / 24, 1)) if int(result['count']) % 100 == 0: info = "最后创建时间" + list_str[ 3] + ",早上到目前:" + today_num + "个,平均一小时:" + today_persent + "个,前一天总数:" + pre_num + "个,前一天平均一小时" + pre_persent + "个,大前天总数" + pre_pre_num + "个,大前天平均一小时" + pre_pre_persent + "个,当前词:" + list_str[ 1] + ",当前num:" + list_str[2] print(info) pop(bar_pop, ['2', info])
def end_order_user_create(self, start_time, create_funs, user_info): end_time = d.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 结束时间 start = create_funs.str_to_int(start_time) end = create_funs.str_to_int(end_time) num = (end - start) / 60 m = int(num) s = (end - start) - m * 60 end_time = d.datetime.now().strftime("%Y-%m-%d %H:%M:%S") info = user_info + '顺序循环结束,开始时间:' + start_time + ',结束时间:' + end_time + ',用时' + str( m) + '分' + str(s) + '秒' function.send_statics_email(info) pop(bar_pop, [0, info])
def end_sigal_user_edit(self, start_time, edit_funs, users, mod): end_time = d.datetime.now().strftime("%Y-%m-%d %H:%M:%S") # 结束时间 start = edit_funs.str_to_int(start_time) end = edit_funs.str_to_int(end_time) num = (end - start) / 60 m = int(num) s = (end - start) - m * 60 end_time = d.datetime.now().strftime("%Y-%m-%d %H:%M:%S") index = mod['index'] - 1 user = users[index] info = '账号:' + user['name'] + '已编辑' + str( mod['each_num'] ) + '个词条(结束),开始时间:' + start_time + ',结束时间:' + end_time + ',用时' + str( m) + '分' + str(s) + '秒' function.send_statics_email(info) print(info) pop(bar_pop, [1, info])