Ejemplo n.º 1
0
def main_wrapper():
    freeze_support()

    logger.info(
        color("bold_green") + f"已将工作目录设置为小助手所在目录:{dirpath},之前为:{old_path}")

    try:
        run_start_time = datetime.datetime.now()
        main()
        total_used_time = datetime.datetime.now() - run_start_time
        logger.warning(color("fg_bold_yellow") + f"运行完成,共用时{total_used_time}")

        # 如果总用时太高的情况时,尝试提示开启多进程和超快速模式
        cfg = config()
        if total_used_time > datetime.timedelta(minutes=10) and (
                not cfg.common.enable_multiprocessing
                or not cfg.common.enable_super_fast_mode):
            msg = (f"当前累计用时似乎很久({total_used_time}),是否要尝试多进程和超快速模式?\n"
                   "多进程模式下,将开启多个进程并行运行不同账号的领取流程\n"
                   "额外开启超快速模式,会进一步将不同账号的不同活动都异步领取,进一步加快领取速度\n"
                   "\n"
                   "如果需要开启,请打开配置工具,在【公共配置】tab中勾选【是否启用多进程功能】和【是否启用超快速模式(并行活动)】")
            logger.warning(color("bold_cyan") + msg)
            if is_weekly_first_run("用时过久提示"):
                async_message_box(msg, "用时过久", print_log=False)

        # 按照分钟级别来统计使用时长
        total_minutes = int(total_used_time.total_seconds()) // 60
        increase_counter(ga_category="run_used_time_minutes",
                         name=total_minutes)
    except Exception as e:
        show_unexpected_exception_message(e)
        # 如果在github action,则继续抛出异常
        if is_run_in_github_action():
            raise e
    finally:
        close_pool()
        # 暂停一下,方便看结果
        if not disable_pause_after_run() and not is_run_in_github_action():
            pause()
Ejemplo n.º 2
0
    init_pool(cfg.get_pool_size())

    change_title("集卡特别版", multiprocessing_pool_size=cfg.get_pool_size())

    show_multiprocessing_info(cfg)

    check_all_skey_and_pskey(cfg)

    # 正式进行流程
    run(cfg)

    auto_send_cards(cfg)
    show_lottery_status("卡片赠送完毕后展示各账号抽卡卡片以及各礼包剩余可领取信息", cfg, need_show_tips=True)

    # 运行结束展示下多进程信息
    show_multiprocessing_info(cfg)


if __name__ == '__main__':
    freeze_support()
    try:
        run_start_time = datetime.datetime.now()
        main()
        logger.warning(color("fg_bold_yellow") + f"运行完成,共用时{datetime.datetime.now() - run_start_time}")
    except Exception as e:
        show_unexpected_exception_message(e)
    finally:
        close_pool()
        # 暂停一下,方便看结果
        pause()