This commit is contained in:
yumoqing 2024-01-19 14:24:11 +08:00
parent 5df13d1cbb
commit 4186659cd0
2 changed files with 4 additions and 3 deletions

View File

@ -44,7 +44,7 @@ if __name__ == '__main__':
i18n = getI18N(path=workdir) i18n = getI18N(path=workdir)
# server = ConfiguredServer(auth_klass=MyAuthAPI, workdir=workdir) # server = ConfiguredServer(auth_klass=MyAuthAPI, workdir=workdir)
server = ConfiguredServer(workdir=workdir) server = ConfiguredServer(workdir=workdir)
load_plugins(workdir) load_plugins(workdir, server)
logger.info(f'gadget version={__version__}') logger.info(f'gadget version={__version__}')
logger.debug(f'debug mode show ?') logger.debug(f'debug mode show ?')
port = args.port or config.website.port or 8080 port = args.port or config.website.port or 8080

View File

@ -4,14 +4,15 @@ import sys
from appPublic.folderUtils import listFile from appPublic.folderUtils import listFile
from appPublic.ExecFile import ExecFile from appPublic.ExecFile import ExecFile
def load_plugins(p_dir): def load_plugins(p_dir, server):
ef = ExecFile() ef = ExecFile()
pdir = os.path.join(p_dir, 'plugins') pdir = os.path.join(p_dir, 'plugins')
if not os.path.isdir(pdir): if not os.path.isdir(pdir):
print('load_plugins:%s not exists' % pdir) print('load_plugins:%s not exists' % pdir)
return return
sys.path.append(pdir) sys.path.append(pdir)
for py in listFile(pdir, suffixs=['.py'], rescursive=True): ef.set('server', server)
for py in listFile(pdir, suffixs=['.py'], rescursive=False):
ef.set('sys',sys) ef.set('sys',sys)
ef.run(py) ef.run(py)