Files
aaPanel/class/public/hook_import.py
T
Jack 6f212ce3d6 Update to 7.27.0
1. Added Domains menu to manage Domains and SSL Certificates
2. Added Add Site automatic record creation when adding websites (Only supported by IPv4)
3. Added Vietnamese language
4. Added Indonesian language
5. Added HTTPS Protection function for Website (disables automatic HTTP to HTTPS redirection when enabled)
6. Added Mail Marketing -- Automation trigger tasks
7. Added Mail Marketing -- Groups Import, Export, Merge
8. Added Mail Marketing -- Subscribers to support paste import
9. Added Mail Marketing -- Template Import Export Duplicate
10. Added Mail server -- Other Settings add timed Auto Responder
11. Added Mail Marketing -- Suspend List to detect abnormal mailboxes
12. Added Mail Marketing -- Marketing Task to export error mail logs
13. Added Mail Domain -- SSL certificate expiration alert
14. Optimized Webmail management to display based on domain additions
15. Optimize Website Interface Button Integration
16. Optimize the response speed of WP Toolkit interface
2025-03-26 09:04:29 +08:00

77 lines
2.0 KiB
Python

# Hook __import__
import builtins
import os
import sys
import public
import public.PluginLoader as plugin_loader
if 'class_v2/' not in sys.path and 'class_v2' not in sys.path:
sys.path.insert(0, 'class_v2/')
__hooked = False
old__import__ = builtins.__import__
def hook_import():
global __hooked
if __hooked:
return
def _aap__import__(name, globals = None, locals = None, fromlist = (), level = 0):
try:
return old__import__(name, globals, locals, fromlist, level)
except SyntaxError:
# searching module in project.
if level == 0 and str(name).strip() != '':
panel_path = public.get_panel_path()
pyfile = '{}.py'.format(str(name).strip().replace('.', '/'))
realpath = ''
cond = False
for p in set(sys.path):
realpath = os.path.join(panel_path, p, pyfile)
cond = os.path.exists(realpath)
if not cond:
continue
break
if not cond:
realpath = os.path.join(panel_path, pyfile)
cond = os.path.exists(realpath)
if cond:
try:
# public.print_log('Load project module: {} {} {} {}'.format(name, level, realpath, fromlist))
m = plugin_loader.get_module(realpath)
if fromlist is None or len(fromlist) == 0:
return m
for prop_name in fromlist:
prop = getattr(m, prop_name)
if globals is not None:
globals[prop_name] = prop
if locals is not None:
locals[prop_name] = prop
return m
except:
raise
raise
builtins.__import__ = _aap__import__
__hooked = True