def check_update_on_start(config: CommonConfig): if config.bypass_proxy: logger.info("检查更新前临时启用代理") use_proxy() check_update = config.check_update_on_start or config.check_update_on_end try: if is_run_in_github_action(): logger.info("当前在github action环境下运行,无需检查更新") return if not check_update and not config.auto_update_on_start: logger.warning("启动时检查更新被禁用,若需启用请在config.toml中设置") return ui = get_update_info(config) if check_update: try_manaual_update(ui) if config.auto_update_on_start: show_update_info_on_first_run(ui) except Exception as e: logger.debug(f"更新失败 {e}") if check_update: update_fallback(config) finally: if config.bypass_proxy: logger.info("检查完毕,继续无视代理") bypass_proxy()
def check_update_on_start(config: CommonConfig): try: if is_run_in_github_action(): logger.info("当前在github action环境下运行,无需检查更新") return if not config.check_update_on_start and not config.auto_update_on_start: logger.warning("启动时检查更新被禁用,若需启用请在config.toml中设置") return ui = get_update_info(config) if config.check_update_on_start: try_manaual_update(ui) if config.auto_update_on_start: show_update_info_on_first_run(ui) except Exception as err: logger.error( f"检查版本更新失败(这个跟自动更新没有任何关系),大概率是访问不了github导致的,可自行前往网盘查看是否有更新, 错误为{err}" + color("bold_green") + f"\n(无法理解上面这段话的话,就当没看见这段话,对正常功能没有任何影响)" ) # 如果一直连不上github,则尝试判断距离上次更新的时间是否已经很长 time_since_last_update = datetime.now() - datetime.strptime(ver_time, "%Y-%m-%d") if time_since_last_update.days >= 7: msg = f"无法访问github确认是否有新版本,而当前版本更新于{ver_time},距今已有{time_since_last_update},很可能已经有新的版本,建议打开目录中的[网盘链接]看看是否有新版本,或者购买自动更新DLC省去手动更新的操作\n\n(如果已购买自动更新DLC,就无视这句话)" logger.info(color("bold_green") + msg) if is_first_run(f"notify_manual_update_if_can_not_connect_github_v{now_version}"): win32api.MessageBox(0, msg, "更新提示", win32con.MB_ICONINFORMATION) webbrowser.open("https://fzls.lanzous.com/s/djc-helper")
def show_tip_on_first_run(first_run_tip_name, title, tips, loginfo, show_count=1): if not is_first_run(f"show_tip_{first_run_tip_name}"): logger.debug(f"{first_run_tip_name} 已经提示过,不再展示") return # 仅在window系统下检查 if platform.system() != "Windows": return # 如果在github action环境下,则不弹窗 if is_run_in_github_action(): return # 若是首次运行,提示相关信息 logger.info(loginfo) for i in range(show_count): _title = title if show_count != 1: _title = f"第{i + 1}/{show_count}次提示 {title}" message_box(tips, _title)
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()
def check_update_on_start(config: CommonConfig): try: if is_run_in_github_action(): logger.info("当前在github action环境下运行,无需检查更新") return if not config.check_update_on_start and not config.auto_update_on_start: logger.warning("启动时检查更新被禁用,若需启用请在config.toml中设置") return ui = get_update_info(config) if config.check_update_on_start: try_manaual_update(ui) if config.auto_update_on_start: show_update_info_on_first_run(ui) except Exception as err: try: # 到这里一般是无法访问github,这时候试试gitee的方案 if config.check_update_on_start: latest_version = get_version_from_gitee() ui = UpdateInfo() ui.latest_version = latest_version ui.netdisk_link = "https://fzls.lanzous.com/s/djc-helper" ui.netdisk_passcode = "fzls" ui.update_message = "当前无法访问github,暂时无法获取更新内容,若欲知更新内容,请浏览gitee主页进行查看哦~\n\nhttps://gitee.com/fzls/djc_helper/blob/master/CHANGELOG.MD" try_manaual_update(ui) except Exception as err: logger.error( f"手动检查版本更新失败(这个跟自动更新没有任何关系),大概率是访问不了github和gitee导致的,可自行前往网盘查看是否有更新, 错误为{err}" + color("bold_green") + f"\n(无法理解上面这段话的话,就当没看见这段话,对正常功能没有任何影响)") # 如果一直连不上github,则尝试判断距离上次更新的时间是否已经很长 time_since_last_update = datetime.now() - datetime.strptime( ver_time, "%Y.%m.%d") if time_since_last_update.days >= 7: msg = f"无法访问github确认是否有新版本,而当前版本更新于{ver_time},距今已有{time_since_last_update},很可能已经有新的版本,建议打开目录中的[网盘链接]看看是否有新版本,或者购买自动更新DLC省去手动更新的操作\n\n(如果已购买自动更新DLC,就无视这句话)" logger.info(color("bold_green") + msg) if is_first_run( f"notify_manual_update_if_can_not_connect_github_v{now_version}" ): win32api.MessageBox(0, msg, "更新提示", win32con.MB_ICONINFORMATION) webbrowser.open("https://fzls.lanzous.com/s/djc-helper")
def check_update_on_start(config: CommonConfig): check_update = config.check_update_on_start or config.check_update_on_end try: if is_run_in_github_action(): logger.info("当前在github action环境下运行,无需检查更新") return if not check_update and not config.auto_update_on_start: logger.warning("启动时检查更新被禁用,若需启用请在config.toml中设置") return ui = get_update_info(config) if check_update: try_manaual_update(ui) if config.auto_update_on_start: show_update_info_on_first_run(ui) except Exception as err: if check_update: update_fallback(config)