def reset(signum): logger = Logger('reset_counter.log') logger.write("Start") try: MongoCounter.objects.delete() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def reset(signum): logger = Logger("reset_hero_panel.log") logger.write("Start") try: HeroPanel.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def clean(signum): logger = Logger("clean_plunder_board_weekly.log") logger.write("Start") try: PlunderLeaderboardWeekly.clean() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def reset(signum): logger = Logger("reset_union_boss.log") logger.write("Start") try: MongoUnionBoss.drop_collection() except: logger.error(traceback.format_exc()) else: logger.write("Rest Complete.") finally: logger.close()
def reset(signum): logger = Logger('reset_store_player_limit.log') logger.write("Start") try: MongoStoreCharLimit.objects.delete() except: logger.error(traceback.format_exc()) else: logger.write("MongoStoreCharLimit Clean Done") finally: logger.close()
def clean(signum): logger = Logger("clean_active_players.log") logger.write("Start.") try: result = ActivePlayers().clean() except: logger.error(traceback.format_exc()) else: logger.write("Complete. {0}".format(result)) finally: logger.close()
def reset(signum): logger = Logger('reset_checkin.log') logger.write("Start") try: CheckIn.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("MongoCheckin Daily Reset Done") finally: logger.close()
def reset_times(signum): logger = Logger("plunder_reset_times.log") logger.write("Start") try: Plunder.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("done") finally: logger.close()
def clean(signum): logger = Logger("union_transfer_owner.log") logger.write("Start") try: result = Union.cronjob_auto_transfer_union() except: logger.error(traceback.format_exc()) else: logger.write("Transfer: {0}".format(json.dumps(result))) finally: logger.close()
def reset(signum): logger = Logger('reset_prize.log') logger.write("Start") try: Attachment.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def clean(signum): logger = Logger("clean_union.log") logger.write("Start") try: UnionBattle.cron_job() Member.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("Clean Union Complete.") finally: logger.close()
def reset(signum): logger = Logger("reset_checkin.log") logger.write("Start") try: CheckIn.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("MongoCheckin Daily Reset Done") finally: logger.close()
def reset(signum): logger = Logger('reset_friend_plunder_times.log') logger.write("Start") try: Friend.cron_job() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def reset(signum): logger = Logger('reset_stage_elite.log') logger.write("Start") try: for ms in MongoStage.objects.filter(elite_changed=True): for k in ms.elites.keys(): ms.elites[k] = 0 ms.elites_buy = {} ms.elite_changed = False ms.save() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def add_times(signum): hour = arrow.utcnow().to(settings.TIME_ZONE).hour if hour >= 1 and hour < 8: return logger = Logger('add_plunder_times.log') logger.write("Start") char_ids = get_char_ids_by_last_login(limit=3) for char_id in char_ids: plunder = Plunder(char_id) try: plunder.change_current_plunder_times(change_value=1, allow_overflow=False) except: logger.error(traceback.format_exc()) logger.write("add done") logger.close()
def reset(signum): logger = Logger("union_reward_week.log") logger.write("Start") try: unions = MongoUnion.objects.all().order_by('-score') rank = 1 for u in unions: if rank > LOWEST_UNION_BATTLE_RANK: break _send_reward(rank, u) rank += 1 except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def set_yueka(signum): logger = Logger('set_yueka.log') logger.write("Start") records = MongoPurchaseRecord.objects.filter(yueka_remained_days__gt=0) for record in records: if record.yueka_remained_days > 0: # 发送奖励,并且days-1 send_yueka_reward(record.id, record.yueka_sycee, record.yueka_remained_days - 1) pa = BasePurchaseAction(record.id) try: pa.set_yueka_remained_days(-1) except YuekaLockTimeOut: logger.error(traceback.format_exc()) logger.write("Done") logger.close()
def clean(signum): logger = Logger("clean_mail.log") logger.write("Start") try: amount = 0 mails = MongoMail._get_collection().find({}, {'_id': 1}) for m in mails: char_id = m['_id'] char_mail = Mail(char_id) cleaned = char_mail.delete_expired(MAIL_KEEP_DAYS) amount += cleaned except: logger.error(traceback.format_exc()) else: logger.write("Clean Mail Complete. Cleaned Amount: {0}".format(amount)) finally: logger.close()
def send_vip_reward(signum): logger = Logger("send_vip_reward.log") logger.write("Start") try: docs = MongoCharacter._get_collection().find({'vip': { '$gte': 6 }}, {'_id': 1}) for doc in docs: char_id = doc['_id'] ac = ActivityEntry(char_id, 22001) if ac and ac.is_valid(): ac.send_mail() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def reset(signum): logger = Logger("union_reward_week.log") logger.write("Start") try: unions = MongoUnion.objects.all().order_by('-score') rank = 1 for u in unions: if rank > LOWEST_UNION_BATTLE_RANK: break _send_reward(rank, u) rank+=1 except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def set_yueka(signum): logger = Logger('set_yueka.log') logger.write("Start") records = MongoPurchaseRecord.objects.filter(yueka_remained_days__gt=0) for record in records: if record.yueka_remained_days > 0: # 发送奖励,并且days-1 send_yueka_reward(record.id, record.yueka_sycee, record.yueka_remained_days-1) pa = BasePurchaseAction(record.id) try: pa.set_yueka_remained_days(-1) except YuekaLockTimeOut: logger.error(traceback.format_exc()) logger.write("Done") logger.close()
def main(signum): logger = Logger('reset_arena_day.log') arena_scores = ArenaScoreManager.get_all() amount = len(arena_scores) logger.write("Reset Arena Day: Start. chars amount: {0}".format(amount)) try: for char_id, score in arena_scores: attachment = _get_reward_by_score(score) if not attachment: continue char_id = int(char_id) mail = Mail(char_id) mail.add(MAIL_ARENA_DAY_REWARD_TITLE, MAIL_ARENA_DAY_REWARD_CONTENT, attachment=attachment) except: logger.error(traceback.format_exc()) else: logger.write("Reset Arena Day: Complete") finally: logger.close()
def send_vip_reward(signum): logger = Logger("send_vip_reward.log") logger.write("Start") try: docs = MongoCharacter._get_collection().find( {'vip': {'$gte': 6}}, {'_id': 1} ) for doc in docs: char_id = doc['_id'] ac = ActivityEntry(char_id, 22001) if ac and ac.is_valid(): ac.send_mail() except: logger.error(traceback.format_exc()) else: logger.write("Done") finally: logger.close()
def reset(signum): logger = Logger("reset_arena_week.log") logger.write("Start Arena Week") try: # 每周奖励 rank_data = get_rank_data(ARENA_WEEK_REWARD_LOWEST_RANK) rank_info_log = ["\n",] for index, data in enumerate(rank_data): rank = index + 1 char_id = data[0] score = data[1] _info_text = "Rank: {0}, Char: {1}, Score: {2}".format(rank, char_id, score) if score < ARENA_RANK_LINE: continue reward = _get_reward_by_rank(rank) if not reward: continue mail = Mail(char_id) mail.add( MAIL_ARENA_WEEK_REWARD_TITLE, MAIL_ARENA_WEEK_REWARD_CONTENT, attachment=json.dumps(reward)) _info_text = "{0}. Send Mail: True".format(_info_text) rank_info_log.append(_info_text) except: logger.error(traceback.format_exc()) else: logger.write("\n".join(rank_info_log)) logger.write("Done Arena Week") finally: logger.close() logger = Logger("reset_arena_week.log") logger.write("Start Arena Achievement") try: # 成就 rank_data = get_rank_data(None) for index, data in enumerate(rank_data): rank = index + 1 char_id = data[0] achievement = Achievement(char_id) achievement.trig(10, rank) except: logger.error(traceback.format_exc()) else: logger.write("Done Arena Achievement") finally: logger.close() logger = Logger("reset_arena_week.log") logger.write("Start Arena Activity 4001") try: # 开服比武奖励 _activity_anera_values = [] for _c in ACTIVITY_STATIC[4001].condition_objs: _activity_anera_values.append(_c.condition_value) LOWEST_RANK = max(_activity_anera_values) rank_data = get_rank_data(LOWEST_RANK) for index, data in enumerate(rank_data): char_id = data[0] ActivityStatic(char_id).trig(4001) except: logger.error(traceback.format_exc()) else: logger.write("Done Arena Activity 4001") finally: logger.close()
def run(signum): logger = Logger('store_refresh_tag_one_goods.log') StoreProduction.make_random_tag_one() logger.write("refresh complete!") logger.close()
def run(signum): connection.close() mails = ModelMail.objects.filter(Q(status=1) & Q(send_at__lte=timezone.now())) logger = Logger('send_mail.log') logger.write('Send Mail Start. mails amount: {0}'.format(mails.count())) servers = make_servers(is_test=False) available_server_ids = [k for k, v in servers.items() if v['status'] != 4] for m in mails: m.status = 2 m.save() logger.write("send {0}...".format(m.id)) try: send_one_mail(m, available_server_ids) except Exception as e: logger.write("==== ERROR ====") logger.write("mail: {0}".format(m.id)) logger.write(str(e)) m.status = 1 else: m.status = 3 m.save() logger.write("Send Mail Complete") logger.close()
def run(signum): connection.close() logger = Logger('check_server.log') servers = make_servers(is_test=False) for s in servers.keys(): try: res = api_check_server(s) except: import traceback logger.write('---- ERROR ----') logger.write(traceback.format_exc()) active_amount = 0 else: active_amount = res['data']['active_amount'] pong_from_server(s, active_amount) logger.write("server {0} active amount {1}".format(s, active_amount)) logger.write("server check complete!") logger.close()
def run(signum): logger = Logger('send_checkin_data.log') logger.write("Send CheckIn Data Start.") checkin_obj = get_checkin_obj() logger.write("Got CheckIn Object: {0}".format(checkin_obj.checkin_date)) data = json.dumps(checkin_obj.export_data()) error_servers = api_send_checkin_data(data) if error_servers: logger.write("ERROR SERVERS: {0}".format(error_servers)) logger.write("Done") logger.close()