feat: 支持从储存库获取插件

This commit is contained in:
Rock Chin
2023-01-17 11:54:33 +08:00
parent b4938ba1fb
commit 120ec98ba7
4 changed files with 57 additions and 23 deletions

View File

@@ -2,6 +2,7 @@
import asyncio
import logging
import importlib
import os
import pkgutil
import sys
import traceback
@@ -108,7 +109,16 @@ def install_plugin(repo_url: str):
from dulwich import porcelain
logging.info("克隆插件储存库: {}".format(repo_url))
repo = porcelain.clone(repo_url, "plugins", checkout=True)
repo = porcelain.clone(repo_url, "plugins/"+repo_url.split(".git")[0].split("/")[-1]+"/", checkout=True)
# 检查此目录是否包含requirements.txt
if os.path.exists("plugins/"+repo_url.split(".git")[0].split("/")[-1]+"/requirements.txt"):
logging.info("检测到requirements.txt正在安装依赖")
import pkg.utils.pkgmgr
pkg.utils.pkgmgr.install_requirements("plugins/"+repo_url.split(".git")[0].split("/")[-1]+"/requirements.txt")
import main
main.reset_logging()
class EventContext:

View File

@@ -59,8 +59,9 @@ def load_switch():
switch_modified = False
switch_copy = switch.copy()
# 检查switch中多余的和path不相符的
for plugin_name in switch:
for plugin_name in switch_copy:
if plugin_name not in host.__plugins__:
del switch[plugin_name]
switch_modified = True