Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Nov 2, 2023
1 parent 8e8a587 commit 8e842c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
19 changes: 11 additions & 8 deletions app/helper/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ def load(cls, package_path, filter_func=lambda name, obj: True):
packages = importlib.import_module(package_path)
importlib.reload(packages)
for importer, package_name, _ in pkgutil.iter_modules(packages.__path__):
if package_name.startswith('_'):
continue
full_package_name = f'{package_path}.{package_name}'
module = importlib.import_module(full_package_name)
for name, obj in module.__dict__.items():
if name.startswith('_'):
try:
if package_name.startswith('_'):
continue
if isinstance(obj, type) and filter_func(name, obj):
submodules.append(obj)
full_package_name = f'{package_path}.{package_name}'
module = importlib.import_module(full_package_name)
for name, obj in module.__dict__.items():
if name.startswith('_'):
continue
if isinstance(obj, type) and filter_func(name, obj):
submodules.append(obj)
except Exception as err:
print(f'加载模块 {package_name} 失败:{err}')

return submodules
6 changes: 4 additions & 2 deletions app/helper/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def __download_files(_p: str, _l: List[dict]) -> Tuple[bool, str]:
f.write(res.text)
else:
# 递归下载子目录
l, m = __get_filelist(f"{_p}/{item.get('name')}")
p = f"{_p}/{item.get('name')}"
l, m = __get_filelist(p)
if not l:
return False, m
return __download_files(_p, _l)
return __download_files(p, l)
return True, ""

if not pid or not repo_url:
Expand Down Expand Up @@ -119,3 +120,4 @@ def __download_files(_p: str, _l: List[dict]) -> Tuple[bool, str]:
shutil.rmtree(plugin_dir, ignore_errors=True)
# 下载所有文件
__download_files(pid.lower(), file_list)
return True, ""

0 comments on commit 8e842c3

Please sign in to comment.