feat: 增加加载器模式
This commit is contained in:
parent
8447273eb7
commit
cc3e6eeb31
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,7 +2,7 @@
|
||||
.idea
|
||||
|
||||
# Python
|
||||
*.pyc
|
||||
__pycache__
|
||||
|
||||
# Data
|
||||
agree-terms
|
||||
@ -10,3 +10,4 @@ data
|
||||
language
|
||||
share.json
|
||||
config.json
|
||||
.DS_Store
|
||||
|
2
loader/.gitignore
vendored
Normal file
2
loader/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
logs/
|
||||
!./binary/*.pyc
|
BIN
loader/binary/api.pyc
Normal file
BIN
loader/binary/api.pyc
Normal file
Binary file not shown.
BIN
loader/binary/globals.pyc
Normal file
BIN
loader/binary/globals.pyc
Normal file
Binary file not shown.
BIN
loader/binary/i18n.pyc
Normal file
BIN
loader/binary/i18n.pyc
Normal file
Binary file not shown.
BIN
loader/binary/login.pyc
Normal file
BIN
loader/binary/login.pyc
Normal file
Binary file not shown.
BIN
loader/binary/main.pyc
Normal file
BIN
loader/binary/main.pyc
Normal file
Binary file not shown.
BIN
loader/binary/utility.pyc
Normal file
BIN
loader/binary/utility.pyc
Normal file
Binary file not shown.
BIN
loader/binary/utils.pyc
Normal file
BIN
loader/binary/utils.pyc
Normal file
Binary file not shown.
1
loader/binary/version.txt
Normal file
1
loader/binary/version.txt
Normal file
@ -0,0 +1 @@
|
||||
0.8.7
|
46
loader/loader.py
Normal file
46
loader/loader.py
Normal file
@ -0,0 +1,46 @@
|
||||
import importlib
|
||||
import importlib.machinery
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
_BINARY_DIR = Path(__file__).parent / 'binary'
|
||||
_MODULES = [
|
||||
'utils',
|
||||
'i18n',
|
||||
'login',
|
||||
'globals',
|
||||
'api',
|
||||
'main',
|
||||
]
|
||||
|
||||
|
||||
def load_binary():
|
||||
sys.path.append(str(_BINARY_DIR))
|
||||
|
||||
# 先载入并 patch utils
|
||||
importlib.import_module('utils')
|
||||
patch_module()
|
||||
|
||||
importlib.import_module('main')
|
||||
return sys.modules['main']
|
||||
|
||||
|
||||
def patch_module():
|
||||
def check_policy():
|
||||
from loguru import logger
|
||||
logger.info('Bypass check_policy')
|
||||
|
||||
sys.modules['utils'].check_policy = check_policy
|
||||
|
||||
|
||||
def run_module(module):
|
||||
module.main()
|
||||
|
||||
|
||||
def main():
|
||||
module = load_binary()
|
||||
run_module(module)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user