2023-08-07 16:40:38 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from appPublic.folderUtils import listFile
|
|
|
|
from appPublic.ExecFile import ExecFile
|
|
|
|
from ahserver.serverenv import ServerEnv
|
2023-10-27 11:43:23 +08:00
|
|
|
import appPublic
|
|
|
|
import sqlor
|
|
|
|
import ahserver
|
2023-08-07 16:40:38 +08:00
|
|
|
|
|
|
|
def load_plugins(p_dir):
|
|
|
|
ef = ExecFile()
|
|
|
|
pdir = os.path.join(p_dir, 'plugins')
|
|
|
|
if not os.path.isdir(pdir):
|
2023-12-18 18:54:15 +08:00
|
|
|
# print('load_plugins:%s not exists' % pdir)
|
2023-08-07 16:40:38 +08:00
|
|
|
return
|
|
|
|
sys.path.append(pdir)
|
|
|
|
ef.set('sys',sys)
|
|
|
|
ef.set('ServerEnv', ServerEnv)
|
2023-08-07 17:13:27 +08:00
|
|
|
for m in listFile(pdir, suffixs='.py'):
|
2023-10-27 11:43:23 +08:00
|
|
|
if m == '__init__.py':
|
2023-08-07 16:40:38 +08:00
|
|
|
continue
|
2023-10-27 11:43:23 +08:00
|
|
|
if not m.endswith('.py'):
|
|
|
|
continue
|
2023-12-18 18:54:15 +08:00
|
|
|
# print(f'{m=}')
|
2023-08-07 17:21:42 +08:00
|
|
|
module = os.path.basename(m[:-3])
|
2023-12-18 18:54:15 +08:00
|
|
|
# print('module=', module)
|
2023-08-07 17:21:42 +08:00
|
|
|
__import__(module, locals(), globals())
|
2023-08-07 16:40:38 +08:00
|
|
|
|