From c56f3be55345e58e1457cc7e71d356ab6dbce061 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:41:13 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E6=89=A7=E8=A1=8C=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/bot_check.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/bot_check.yml b/.github/workflows/bot_check.yml index 1a5ed8cf..0adf66ab 100644 --- a/.github/workflows/bot_check.yml +++ b/.github/workflows/bot_check.yml @@ -54,7 +54,6 @@ jobs: - name: Install dependencies if: steps.cache-poetry.outputs.cache-hit != 'true' run: | - rm -rf poetry.lock poetry source remove aliyun poetry install --no-root @@ -63,8 +62,8 @@ jobs: run: | poetry run sudo apt-get update poetry run sudo apt-get install -y libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav flite x264 libx264-dev - poetry run sudo playwright install-deps poetry run pip install playwright + poetry run sudo playwright install-deps poetry run sudo playwright install - name: Run tests From fabc7444df0371307e1c0e59b335d12e6db3e104 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:42:37 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/builtin_plugins/plugin_store/test_update_all_plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/builtin_plugins/plugin_store/test_update_all_plugin.py b/tests/builtin_plugins/plugin_store/test_update_all_plugin.py index 640391c8..7fc3b588 100644 --- a/tests/builtin_plugins/plugin_store/test_update_all_plugin.py +++ b/tests/builtin_plugins/plugin_store/test_update_all_plugin.py @@ -57,7 +57,9 @@ async def test_update_all_plugin_basic_need_update( ) ctx.should_call_send( event=event, - message=Message(message="已更新插件 识图\n共计1个插件! 重启后生效"), + message=Message( + message="--已更新1个插件 0个失败 1个成功--\n* 以下插件更新成功:\n\t- 识图\n重启后生效" # noqa: E501 + ), result=None, bot=bot, ) From 627f02fd2258d14886da7cfea68bc024ee0a7f99 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:43:51 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=95=86=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin_store/data_source.py | 75 +++++++++++-------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/zhenxun/builtin_plugins/plugin_store/data_source.py b/zhenxun/builtin_plugins/plugin_store/data_source.py index 818fb53f..a9a058a6 100644 --- a/zhenxun/builtin_plugins/plugin_store/data_source.py +++ b/zhenxun/builtin_plugins/plugin_store/data_source.py @@ -256,12 +256,11 @@ class ShopManage: result = await AsyncHttpx.gather_download_file( req_download_urls, req_paths ) - for _id, success in enumerate(result): + for success in result: if not success: raise Exception("插件依赖文件下载失败") - else: - logger.debug(f"插件依赖文件列表: {req_paths}", "插件管理") - install_requirement(plugin_path) + logger.debug(f"插件依赖文件列表: {req_paths}", "插件管理") + install_requirement(plugin_path) return True raise Exception("插件下载失败") @@ -389,35 +388,51 @@ class ShopManage: """ data: dict[str, StorePluginInfo] = await cls.get_data() plugin_list = list(data.keys()) - update_list = [] + update_failed_list = [] + update_success_list = [] + result = "--已更新{}个插件 {}个失败 {}个成功--" logger.info(f"尝试更新全部插件 {plugin_list}", "插件管理") for plugin_key in plugin_list: - plugin_info = data[plugin_key] - plugin_list = await cls.get_loaded_plugins("module", "version") - suc_plugin = {p[0]: (p[1] or "Unknown") for p in plugin_list} - if plugin_info.module not in [p[0] for p in plugin_list]: - logger.debug(f"插件 {plugin_key} 未安装,跳过", "插件管理") - continue - if cls.check_version_is_new(plugin_info, suc_plugin): - logger.debug(f"插件 {plugin_key} 已是最新版本,跳过", "插件管理") - continue - logger.info(f"正在更新插件 {plugin_key}", "插件管理") - is_external = True - if plugin_info.github_url is None: - plugin_info.github_url = DEFAULT_GITHUB_URL - is_external = False - await cls.install_plugin_with_repo( - plugin_info.github_url, - plugin_info.module_path, - plugin_info.is_dir, - is_external, - ) - update_list.append(plugin_key) - if len(update_list) == 0: + try: + plugin_info = data[plugin_key] + plugin_list = await cls.get_loaded_plugins("module", "version") + suc_plugin = {p[0]: (p[1] or "Unknown") for p in plugin_list} + if plugin_info.module not in [p[0] for p in plugin_list]: + logger.debug(f"插件 {plugin_key} 未安装,跳过", "插件管理") + continue + if cls.check_version_is_new(plugin_info, suc_plugin): + logger.debug(f"插件 {plugin_key} 已是最新版本,跳过", "插件管理") + continue + logger.info(f"正在更新插件 {plugin_key}", "插件管理") + is_external = True + if plugin_info.github_url is None: + plugin_info.github_url = DEFAULT_GITHUB_URL + is_external = False + await cls.install_plugin_with_repo( + plugin_info.github_url, + plugin_info.module_path, + plugin_info.is_dir, + is_external, + ) + update_success_list.append(plugin_key) + except Exception as e: + logger.error(f"更新插件 {plugin_key} 失败: {e}", "插件管理") + update_failed_list.append(plugin_key) + if not update_success_list and not update_failed_list: return "全部插件已是最新版本" - return "已更新插件 {}\n共计{}个插件! 重启后生效".format( - "\n- ".join(update_list), len(update_list) - ) + if update_success_list: + result += "\n* 以下插件更新成功:\n\t- {}".format( + "\n\t- ".join(update_success_list) + ) + if update_failed_list: + result += "\n* 以下插件更新失败:\n\t- {}".format( + "\n\t- ".join(update_failed_list) + ) + return result.format( + len([*update_success_list,*update_failed_list]), + len(update_failed_list), + len(update_success_list), + ) + "\n重启后生效" @classmethod async def _resolve_plugin_key(cls, plugin_id: int | str) -> str: From c00e345f9228a9689503a81d3e0fe60e4dc7df2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:45:03 +0000 Subject: [PATCH 4/7] :rotating_light: auto fix by pre-commit hooks --- zhenxun/builtin_plugins/plugin_store/data_source.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zhenxun/builtin_plugins/plugin_store/data_source.py b/zhenxun/builtin_plugins/plugin_store/data_source.py index a9a058a6..140c40e5 100644 --- a/zhenxun/builtin_plugins/plugin_store/data_source.py +++ b/zhenxun/builtin_plugins/plugin_store/data_source.py @@ -428,11 +428,14 @@ class ShopManage: result += "\n* 以下插件更新失败:\n\t- {}".format( "\n\t- ".join(update_failed_list) ) - return result.format( - len([*update_success_list,*update_failed_list]), + return ( + result.format( + len([*update_success_list, *update_failed_list]), len(update_failed_list), len(update_success_list), - ) + "\n重启后生效" + ) + + "\n重启后生效" + ) @classmethod async def _resolve_plugin_key(cls, plugin_id: int | str) -> str: From 96b45671464577c1c8b054809843650453936ccf Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:49:11 +0800 Subject: [PATCH 5/7] Update bot_check.yml --- .github/workflows/bot_check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/bot_check.yml b/.github/workflows/bot_check.yml index 0adf66ab..21993bee 100644 --- a/.github/workflows/bot_check.yml +++ b/.github/workflows/bot_check.yml @@ -6,12 +6,14 @@ on: paths: - zhenxun/** - tests/** + - .github/workflows/bot_check.yml - bot.py pull_request: branches: ["main"] paths: - zhenxun/** - tests/** + - .github/workflows/bot_check.yml - bot.py jobs: @@ -54,6 +56,7 @@ jobs: - name: Install dependencies if: steps.cache-poetry.outputs.cache-hit != 'true' run: | + rm -rf poetry.lock poetry source remove aliyun poetry install --no-root From 5f3e76bd173ba9528f6a100b95a2e67d43725af5 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:55:48 +0800 Subject: [PATCH 6/7] Update bot_check.yml --- .github/workflows/bot_check.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bot_check.yml b/.github/workflows/bot_check.yml index 21993bee..cdaf0228 100644 --- a/.github/workflows/bot_check.yml +++ b/.github/workflows/bot_check.yml @@ -56,17 +56,17 @@ jobs: - name: Install dependencies if: steps.cache-poetry.outputs.cache-hit != 'true' run: | - rm -rf poetry.lock + rm -rf poetry.lock poetry source remove aliyun poetry install --no-root - + - name: Install playwright if: steps.cache-playwright.outputs.cache-hit != 'true' run: | poetry run sudo apt-get update poetry run sudo apt-get install -y libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav flite x264 libx264-dev poetry run pip install playwright - poetry run sudo playwright install-deps + poetry run sudo playwright install-deps poetry run sudo playwright install - name: Run tests From 8c3dcd644577ce8646c59b3e7fecacdf5f3653e1 Mon Sep 17 00:00:00 2001 From: molanp <104612722+molanp@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:06:16 +0800 Subject: [PATCH 7/7] Update bot_check.yml --- .github/workflows/bot_check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bot_check.yml b/.github/workflows/bot_check.yml index cdaf0228..3731ded8 100644 --- a/.github/workflows/bot_check.yml +++ b/.github/workflows/bot_check.yml @@ -66,8 +66,8 @@ jobs: poetry run sudo apt-get update poetry run sudo apt-get install -y libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav flite x264 libx264-dev poetry run pip install playwright - poetry run sudo playwright install-deps - poetry run sudo playwright install + poetry run playwright install-deps + poetry run playwright install - name: Run tests run: poetry run pytest --cov=zhenxun --cov-report xml